Because all widgets are event black holes.

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Because all widgets are event black holes.

Post by andresdt » Tue Apr 13, 2021 4:12 pm

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.

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Because all widgets are event black holes.

Post by PaulDaMacMan » Wed May 26, 2021 10:32 pm

andresdt wrote:
Tue Apr 13, 2021 4:12 pm
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.
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.

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
There's been a few things with LCB where I've thought "it would be great to have an tool to do that with LCB automagically!". Another example would be creating a foreign type definition binding string, I've had to create structs that translate to ridiculously long LCB foreign-type strings (I did actually start creating a stack for this).
Last edited by PaulDaMacMan on Wed May 26, 2021 11:14 pm, edited 3 times in total.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Because all widgets are event black holes.

Post by PaulDaMacMan » Wed May 26, 2021 11:09 pm

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).
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “LiveCode Builder”