inplace refactorings: check reference at caret according to selection (PY-9309)
javafx: check read-only status
extracted common code