Because when I want to use a widget in my project, I have to watch to see if its developer remembered to tell it to pass the mouseUp event or whatever it needs. Although I don't have much experience in LCB, I have seen that to create a widget you need to call the library “com.livecode.widget”. So I wonder if it would be possible that this library had a mechanism to pass all the events that are not used in the widget.
Example if I have a widget that uses mouseDown for something internal. This takes precedence over the library, but the widget still receives all other events. After all, widgets are controls and should respond to all engine events that other controls respond to.
The idea of putting that mechanism in com.livecode.widget is because I think you won't need to recompile all the widgets.
Because all widgets are event black holes.
-
- Posts: 632
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Because all widgets are event black holes.
Actually it's com.livecode.engine that is the module that contains the syntax for posting messages back to the LC Script engine, amongst other things. What these messages are is completely arbitrary, they can be "mouseUp" with mouse button param or you can make up your own, something like "gridMouseUp" with a x,y position as a parameter, or you can send both if you want.andresdt wrote: ↑Tue Apr 13, 2021 4:12 pmBecause when I want to use a widget in my project, I have to watch to see if its developer remembered to tell it to pass the mouseUp event or whatever it needs. Although I don't have much experience in LCB, I have seen that to create a widget you need to call the library “com.livecode.widget”. So I wonder if it would be possible that this library had a mechanism to pass all the events that are not used in the widget.
Example if I have a widget that uses mouseDown for something internal. This takes precedence over the library, but the widget still receives all other events. After all, widgets are controls and should respond to all engine events that other controls respond to.
The idea of putting that mechanism in com.livecode.widget is because I think you won't need to recompile all the widgets.
It would be nice to make a stack or something that could do things like insert template functions for common events like onMouseUp, onMouseMove, etc. that would have the basic code for posting that type of message
For example:
Code: Select all
public handler onMouseMove()
post "mouseMove" with [the mouse x, the mouse y]
end handler
Last edited by PaulDaMacMan on Wed May 26, 2021 11:14 pm, edited 3 times in total.
-
- Posts: 632
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Because all widgets are event black holes.
My bad, I just looked at "com.livecode.widget" and that does have the common message handlers that LCB can respond to if the dev wants, but it's "com.livecode.engine" that contains the syntax for: post to script object, evaluate script, etc. which I don't think is dependent on the widget module, you can post messages back to the engine from an LCB library (as opposed to an LCB widget).