mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:48:11 +00:00
LibGUI+WindowServer: Add support for enabled/disabled actions.
The enabled state of a GAction now propagates both to any toolbar buttons and any menu items linked to the action. Toolbar buttons are painted in a grayed out style when disabled. Menu items are gray when disabled. :^)
This commit is contained in:
parent
32e5c8c689
commit
054c982181
20 changed files with 308 additions and 53 deletions
|
@ -128,16 +128,21 @@ int main(int argc, char** argv)
|
|||
|
||||
toolbar->add_separator();
|
||||
|
||||
toolbar->add_action(move(cut_action));
|
||||
toolbar->add_action(move(copy_action));
|
||||
toolbar->add_action(cut_action.copy_ref());
|
||||
toolbar->add_action(copy_action.copy_ref());
|
||||
toolbar->add_action(move(paste_action));
|
||||
toolbar->add_action(move(delete_action));
|
||||
toolbar->add_action(delete_action.copy_ref());
|
||||
|
||||
toolbar->add_separator();
|
||||
|
||||
toolbar->add_action(move(undo_action));
|
||||
toolbar->add_action(move(redo_action));
|
||||
|
||||
text_editor->on_selection_change = [&] {
|
||||
cut_action->set_enabled(text_editor->has_selection());
|
||||
copy_action->set_enabled(text_editor->has_selection());
|
||||
};
|
||||
|
||||
auto* window = new GWindow;
|
||||
window->set_title(String::format("TextEditor: %s", path.characters()));
|
||||
window->set_rect(20, 200, 640, 400);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue