Events & Handlers
The core of Nimbus logic. Learn how to respond to user interactions like clicks, inputs, and more.
How it Works
Nimbus separates UI from Logic. You define the UI structure in the <UI> section and the behavior in the <Logic> section.
1. Event Trigger
A user interacts with a control (e.g., clicks a button).
2. Binding
The control's event attribute (e.g., onClick) points to a Handler name.
3. Execution
The Engine finds the Handler in <Logic> and executes its commands.
App.xml
<UI>
<Button Content="Save" onClick="SaveData"/>
</UI>
<Logic>
<Handler Name="SaveData">
<Toast Message="Data Saved!"/>
</Handler>
</Logic>
Click Events
The most common event. Triggered when a user clicks on a Button, Card, or any interactive element.
| Event | Description |
|---|---|
onClick | Triggered on left mouse click. |
onRightClick | Triggered on right mouse click. |
onDoubleClick | Triggered on double click (v3.1+). |
<!-- Button Click -->
<Button Content="Submit" onClick="SubmitForm"/>
<!-- Image Right Click (Context Menu) -->
<Image Source="photo.jpg" onRightClick="ShowMenu"/>
<!-- Card Click -->
<GlassCard onClick="OpenDetails" Cursor="Hand">
<TextBlock Text="Click Me"/>
</GlassCard>
Input Events
Triggered when the value of an input control changes.
| Event | Supported Controls |
|---|---|
onChange / onTextChanged | TextBox, PasswordBox |
onValueChanged | Slider, ProgressBar |
onSelectionChanged | ComboBox, ListBox |
onCheck / onUncheck | CheckBox |
<!-- Text Input -->
<TextBox Name="txtName" onChange="ValidateName"/>
<!-- Slider Change -->
<Slider Minimum="0" Maximum="100" onValueChanged="UpdateVolume"/>
<!-- Checkbox -->
<CheckBox Content="Dark Mode" onCheck="EnableDark" onUncheck="DisableDark"/>
Tip: For TextBox,
onChange fires on every keystroke. Use it for real-time validation or search filtering.
Lifecycle Events
Events that happen automatically during the application's life.
<App Name="My App" OnLoad="AppStart">
...
</App>
<Logic>
<Handler Name="AppStart">
<!-- Logic to run when app opens -->
<Set Var="isReady" Value="true"/>
<Toast Message="Welcome back!"/>
</Handler>
</Logic>
Calling Handlers
You can call one handler from another using the <Call> command. This allows for code reuse and modular logic.
<Handler Name="MainLogic">
<!-- Do some work -->
<Set Var="status" Value="processing"/>
<!-- Call another handler -->
<Call Handler="UpdateUI"/>
<Call Handler="LogActivity"/>
</Handler>
<Handler Name="UpdateUI">
<Set Target="lblStatus" Property="Text" Value="{status}"/>
</Handler>