new method to get selected text

public getter method to get current selected text from the editor.
used to avoid code duplication but more important for me i need it for get the selection so i can prefill search panel textbox in dlangide.
This commit is contained in:
Keywan Ghadami 2016-03-08 11:44:55 +01:00
parent d47825e6aa
commit 56cc745320
1 changed files with 7 additions and 2 deletions

View File

@ -1111,6 +1111,11 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
return true;
}
public dstring getSelectedText(){
dstring selectionText = concatDStrings(_content.rangeText(_selectionRange));
return selectionText;
}
protected bool removeRangeText(TextRange range) {
if (range.empty)
return false;
@ -1310,13 +1315,13 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
return true;
case Copy:
if (!_selectionRange.empty) {
dstring selectionText = concatDStrings(_content.rangeText(_selectionRange));
dstring selectionText = getSelectedText();
platform.setClipboardText(selectionText);
}
return true;
case Cut:
if (!_selectionRange.empty) {
dstring selectionText = concatDStrings(_content.rangeText(_selectionRange));
dstring selectionText = getSelectedText();
platform.setClipboardText(selectionText);
if (readOnly)
return true;