class Crysterm::Action

Overview

Many common commands can be invoked via different interfaces (menus, toolbar buttons, keyboard shortcuts, etc.). Because they are expected to run in the same way, regardless of the user interface used, it is useful to represent them with Actions.

Actions can be added to menus and toolbars, and will automatically be kept in sync because they are the same object. For example, if the user presses a "Bold" toolbar button in a text editor, the "Bold" menu item will automatically appear enabled where ever it is added.

It is recommended to create Actions as children of the window they are used in.

Actions are added to Widgets using #addAction or <<(Action). Note that an action must be added to a widget before it can be used.

NOTE Actions are inspired by QAction (https://doc.qt.io/qt-6/qaction.html)

Included Modules

Defined in:

action.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(parent : EventHandler | Nil = nil) #

[View source]
def self.new(text : String, parent : EventHandler | Nil = nil) #

[View source]

Instance Method Detail

def activate(event : OneOfEvents = Crysterm::Event::Triggered) #

Activates the action


[View source]
def enabled : Bool #

Action enabled?


[View source]
def enabled=(enabled : Bool) #

Action enabled?


[View source]
def shortcut : KeySequence | Nil #

[View source]
def shortcut=(shortcut : KeySequence | Nil) #

[View source]
def status_tip : String | Nil #

Tip to show in status bar, if/when applicable


[View source]
def status_tip=(status_tip : String | Nil) #

Tip to show in status bar, if/when applicable


[View source]
def text : String #

Text / label of action


[View source]
def text=(text : String) #

Text / label of action


[View source]
def tool_tip=(tool_tip : String | Nil) #

Tip to show in a popup on hover over the action, if/when applicable


[View source]
def visible=(visible : Bool) #

This property holds whether the action can be seen (e.g. in menus and toolbars) or is hidden.


[View source]
def visible? : Bool #

This property holds whether the action can be seen (e.g. in menus and toolbars) or is hidden.


[View source]
def whats_this : String | Nil #

Tip to show in a popup when broader help text / description is requested


[View source]
def whats_this=(whats_this : String | Nil) #

Tip to show in a popup when broader help text / description is requested


[View source]