mirror of https://github.com/buggins/dlangui.git
implement default popup menu for EditLine - close #459
This commit is contained in:
parent
ecf3f1cc56
commit
a11b1ef8fb
|
@ -745,6 +745,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
fnlayout.layoutWidth(FILL_PARENT);
|
||||
_edFilename = new EditLine("filename");
|
||||
_edFilename.layoutWidth(FILL_PARENT);
|
||||
_edFilename.setDefaultPopupMenu();
|
||||
if (_flags & FileDialogFlag.SelectDirectory) {
|
||||
_edFilename.visibility = Visibility.Gone;
|
||||
}
|
||||
|
@ -1085,6 +1086,11 @@ class FilePathPanel : FrameLayout {
|
|||
addChild(_segments);
|
||||
addChild(_edPath);
|
||||
}
|
||||
|
||||
void setDefaultPopupMenu() {
|
||||
_edPath.setDefaultPopupMenu();
|
||||
}
|
||||
|
||||
protected bool onEditorFocusChanged(Widget source, bool focused) {
|
||||
if (!focused) {
|
||||
_edPath.text = toUTF32(_path);
|
||||
|
@ -1147,6 +1153,10 @@ class FileNameEditLine : HorizontalLayout {
|
|||
return _edFileName.enterKey;
|
||||
}
|
||||
|
||||
void setDefaultPopupMenu() {
|
||||
_edFileName.setDefaultPopupMenu();
|
||||
}
|
||||
|
||||
this(string ID = null) {
|
||||
super(ID);
|
||||
_caption = UIString.fromId("TITLE_OPEN_FILE"c).value;
|
||||
|
|
|
@ -44,6 +44,7 @@ class InputBox : Dialog {
|
|||
_editor.contentChange = delegate(EditableContent content) {
|
||||
_text = content.text;
|
||||
};
|
||||
_editor.setDefaultPopupMenu();
|
||||
addChild(msg);
|
||||
addChild(_editor);
|
||||
addChild(createButtonsPanel(_actions, _defaultButtonIndex, 0));
|
||||
|
|
|
@ -228,6 +228,12 @@ void initStandardEditorActions() {
|
|||
registerActionEnum!EditorActions();
|
||||
}
|
||||
|
||||
const Action ACTION_EDITOR_COPY = (new Action(EditorActions.Copy, "MENU_EDIT_COPY"c, null, KeyCode.KEY_C, KeyFlag.Control)).addAccelerator(KeyCode.INS, KeyFlag.Control).disableByDefault();
|
||||
const Action ACTION_EDITOR_PASTE = (new Action(EditorActions.Paste, "MENU_EDIT_PASTE"c, null, KeyCode.KEY_V, KeyFlag.Control)).addAccelerator(KeyCode.INS, KeyFlag.Shift).disableByDefault();
|
||||
const Action ACTION_EDITOR_CUT = (new Action(EditorActions.Cut, "MENU_EDIT_CUT"c, null, KeyCode.KEY_X, KeyFlag.Control)).addAccelerator(KeyCode.DEL, KeyFlag.Shift).disableByDefault();
|
||||
const Action ACTION_EDITOR_UNDO = (new Action(EditorActions.Undo, "MENU_EDIT_UNDO"c, null, KeyCode.KEY_Z, KeyFlag.Control)).disableByDefault();
|
||||
const Action ACTION_EDITOR_REDO = (new Action(EditorActions.Redo, "MENU_EDIT_REDO"c, null, KeyCode.KEY_Y, KeyFlag.Control)).addAccelerator(KeyCode.KEY_Z, KeyFlag.Control|KeyFlag.Shift).disableByDefault();
|
||||
|
||||
const Action ACTION_EDITOR_INSERT_NEW_LINE = (new Action(EditorActions.InsertNewLine, KeyCode.RETURN, 0, ActionStateUpdateFlag.never)).addAccelerator(KeyCode.RETURN, KeyFlag.Shift);
|
||||
const Action ACTION_EDITOR_PREPEND_NEW_LINE = (new Action(EditorActions.PrependNewLine, KeyCode.RETURN, KeyFlag.Control | KeyFlag.Shift, ActionStateUpdateFlag.never));
|
||||
const Action ACTION_EDITOR_APPEND_NEW_LINE = (new Action(EditorActions.AppendNewLine, KeyCode.RETURN, KeyFlag.Control, ActionStateUpdateFlag.never));
|
||||
|
@ -249,7 +255,9 @@ const Action[] STD_EDITOR_ACTIONS = [ACTION_EDITOR_INSERT_NEW_LINE, ACTION_EDITO
|
|||
ACTION_EDITOR_SELECT_ALL, ACTION_EDITOR_TOGGLE_LINE_COMMENT, ACTION_EDITOR_TOGGLE_BLOCK_COMMENT,
|
||||
ACTION_EDITOR_TOGGLE_BOOKMARK, ACTION_EDITOR_GOTO_NEXT_BOOKMARK, ACTION_EDITOR_GOTO_PREVIOUS_BOOKMARK,
|
||||
ACTION_EDITOR_FIND, ACTION_EDITOR_REPLACE,
|
||||
ACTION_EDITOR_FIND_NEXT, ACTION_EDITOR_FIND_PREV
|
||||
ACTION_EDITOR_FIND_NEXT, ACTION_EDITOR_FIND_PREV,
|
||||
ACTION_EDITOR_COPY, ACTION_EDITOR_PASTE, ACTION_EDITOR_CUT,
|
||||
ACTION_EDITOR_UNDO, ACTION_EDITOR_REDO
|
||||
];
|
||||
|
||||
/// base for all editor widgets
|
||||
|
@ -2042,6 +2050,15 @@ class EditLine : EditWidgetBase {
|
|||
onThemeChanged();
|
||||
}
|
||||
|
||||
/// sets default popup menu with copy/paste/cut/undo/redo
|
||||
EditLine setDefaultPopupMenu() {
|
||||
MenuItem items = new MenuItem();
|
||||
items.add(ACTION_EDITOR_COPY, ACTION_EDITOR_PASTE, ACTION_EDITOR_CUT,
|
||||
ACTION_EDITOR_UNDO, ACTION_EDITOR_REDO);
|
||||
popupMenu = items;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected dstring _measuredText;
|
||||
protected int[] _measuredTextWidths;
|
||||
protected Point _measuredTextSize;
|
||||
|
|
|
@ -1 +1 @@
|
|||
v0.9.148
|
||||
v0.9.149
|
|
@ -54,3 +54,9 @@ MESSAGE_ERROR=Error
|
|||
MESSAGE_PATH=Path
|
||||
MESSAGE_EXECUTABLES=Executable files
|
||||
MESSAGE_ALL_FILES=All files
|
||||
|
||||
MENU_EDIT_COPY=&Copy
|
||||
MENU_EDIT_PASTE=&Paste
|
||||
MENU_EDIT_CUT=Cu&t
|
||||
MENU_EDIT_UNDO=&Undo
|
||||
MENU_EDIT_REDO=&Redo
|
||||
|
|
|
@ -52,3 +52,9 @@ MESSAGE_ERROR=Ошибка
|
|||
MESSAGE_PATH=Путь
|
||||
MESSAGE_EXECUTABLES=Исполняемые файлы
|
||||
MESSAGE_ALL_FILES=Все файлы
|
||||
|
||||
MENU_EDIT_COPY=&Копировать
|
||||
MENU_EDIT_PASTE=&Вставить
|
||||
MENU_EDIT_CUT=Вырезать
|
||||
MENU_EDIT_UNDO=&Отмена
|
||||
MENU_EDIT_REDO=&Повторить
|
||||
|
|
Loading…
Reference in New Issue