uvi-script
Musical event scripting with Lua
ModifierKeys Class Reference

Keyboard modifier key state information. More...

Public Attributes

bool altDown
 True if the ALT key (Option on macOS) is pressed.
 
bool commandDown
 True if the Command key (macOS) or Ctrl key (Windows/Linux) is pressed.
 
bool shiftDown
 True if the Shift key is pressed.
 

Detailed Description

Keyboard modifier key state information.

Provides information about which modifier keys (Alt, Command/Ctrl, Shift) are pressed when a widget's changed callback is triggered. This allows scripts to implement different behaviors based on modifier key combinations.

Availability: Modifier key information is passed as the second parameter to the changed callback for Button, OnOffButton, and MultiStateButton widgets. When a script sets an OnOffButton or MultiStateButton value, the callback still gets an object, but it reflects the last click rather than the change. It gets nil when the callback is called by push() or called directly (button:changed()), so guard before reading it.

Usage Example:

local button = Button("MyButton")
button.changed = function(self, mods)
if not mods then
print("pushed from script")
elseif mods.shiftDown then
print("Shift-clicked!")
elseif mods.commandDown then
print("Command/Ctrl-clicked!")
elseif mods.altDown then
print("Alt-clicked!")
else
print("Normal click")
end
end
stateless transient button.
Definition ui.cpp:1036
bool altDown
True if the ALT key (Option on macOS) is pressed.
Definition ui.cpp:961
bool commandDown
True if the Command key (macOS) or Ctrl key (Windows/Linux) is pressed.
Definition ui.cpp:962
bool shiftDown
True if the Shift key is pressed.
Definition ui.cpp:963
Note
On macOS, commandDown represents the Command key (⌘). On Windows and Linux, it represents the Ctrl key.
See also
Button, OnOffButton, MultiStateButton