Closed sergioro9 closed 11 months ago
Glimmer DSL for SWT actually supports this sort of behavior via general control listeners. All controls in it support on_mouse_down
for example:
window {
text {
on_mouse_down do
message_box {
text 'Mouse Event'
message 'Mouse Down'
}.open
end
}
}.show
However, Glimmer DSL for LibUI does not support general mouse and keyboard event listeners. Each control has its own unique listeners only.
I just reported the need for supporting general control mouse listeners (and other general listeners) at the upstream libui-ng C library project: https://github.com/libui-ng/libui-ng/issues/219
Thank you for reporting this. In the meantime, you could try to accomplish your needs using Glimmer DSL for SWT or another Glimmer GUI toolkit that supports the feature you need.
I need the button to look like plain text... I haven't found a button property that can do that.
What about a custom button control with area
? Here is an example:
require 'glimmer-dsl-libui'
include Glimmer
window('Area Label', 400, 400) {
area {
text(161, 40, 100) { # declarative stable text
string('Click me!') {
font family: 'Arial', size: (OS.mac? ? 14 : 11)
color :white
}
}
on_mouse_down do |area_mouse_event|
msg_box('mouse event', 'mouse down')
end
}
}.show
@cody271 is a genius! Not only does he maintain the underlying libui-ng library in C, but he also writes great Ruby code too! (BTW, on_mouse_up could have been used too if the mouse up action is preferred as the trigger as that is closer to the button on_clicked behavior)
It seems that :on_click is not available for :text element. Could this be added in future versions? Alternatively, I could use :on_click in a :button but I need the button to look like plain text... I haven't found a button property that can do that.