Page 1 of 1
No messages in widgets?
Posted: Tue Sep 18, 2018 4:45 pm
by dunbarx
Hermann mentioned this to me in another thread. I wrote:
...Messages seem to be blocked in a widget. Even rawKeyDown.
So there is no communication between the LC script and LC builder worlds???
Anyone? Does this seem reasonable? I am not able to determine if the cursor simply enters the widget rect itself? The widget has a script, but that is rather limited in usefulness if no messages can be trapped.
Is it inherent in the nature of widgets?
Craig
Re: No messages in widgets?
Posted: Tue Sep 18, 2018 4:57 pm
by Klaus
Hi Craig,
as far as I understand this, widget will only support those messages, that the deveolper had implemented in the widget.
"mouse" messages are however said to work in all widgets:
https://quality.livecode.com/show_bug.cgi?id=21480
Best
Klaus
Re: No messages in widgets?
Posted: Tue Sep 18, 2018 6:01 pm
by dunbarx
Klaus and all:
I just read:
http://forums.livecode.com/viewtopic.ph ... 46#p126346
This was written several years ago, but details most of the issue.
The one thing I picked out in the first post above, that seems to have been in LCMark's mind, was that the script object of a widget in particular might naturally be seen as a place for "general purpose" messages to be trapped, that is, those not explicitly included by the widget author.
Mark makes the point, which I see the merit of, that the ability to trap any old message might break something in the widget itself, if it explicitly did not include it, or handled it at a lower level within LCB.
Apparently, this has not gone much further since then.
Craig
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 10:38 am
by [-hh]
Craig and Klaus.
All mouse messages are blocked by LCB if the author doesn't implement them.
See the line-graph widget source, no handler begins with OnMouse:
https://github.com/livecode/livecode/bl ... /graph.lcb
TMHO this is exactly the correct way, else I had to block everything I don't want or can't have in my widget. This is NOT a bug.
For example if you draw sliders as in my color picker widget, then you can't accept any other mouseEvent for the user:
If you have built a Porsche (LCB 9 has become pretty fast with a lot of things) then you don't want to add a trailer with all possible camping stuff for the users.
As long as it is open source, there is no problem with that. We have the source and we are developers.
So we can write our own and pass the mouse events we would like to play with.
Also there are not-to-hard ways in LC Script to work around not-sent-messages.
What widget authors should do is to describe in every widget for the Docs which messages are supported (all others are not).
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 10:45 am
by Klaus
Hi Hermann,
[-hh] wrote: ↑Wed Sep 19, 2018 10:38 am
All mouse messages are blocked by LCB if the author doesn't implement them.
so Panos is wrong here:
https://quality.livecode.com/show_bug.cgi?id=21480
?
Best
Klaus
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 10:54 am
by [-hh]
No. He is right.
Because these messages ARE "forwarded" to LC Script by the svg-icon-path widget.
- mouseDown
- mouseUp
- mouseDoubleUp
- mouseEnter
- mouseLeave
no other mouse event.
That's what I say.
What widget authors should do is to describe in every widget for the Docs which [mouse] messages are supported (all others are not).
I'll start with it in my widgets right now.
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 11:00 am
by Klaus
Aaa, thank you.
Still a littele puzzeld, so e.g. the SVG widget simply "passes" (like in a LCS) these messages, so the IDE/LCS/WE can handle them (or not)?
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 11:12 am
by [-hh]
Exactly. In LCB this is called
script access (not allowed in all handlers!).
A message is "forwarded/passed" to the scriptObject (=by default the widget) with "post", for example from the source code of the svg-icon-path widget (comments by me):
Code: Select all
public handler OnMouseUp() -- the widget receives the message in LCB
if the click count is 2 then
post "mouseDoubleUp" with [the click button formatted as string]
--> you can script "on mouseDoubleUp tBtn"
--> in the widget script or card script or ... (up)
else
post "mouseUp" with [the click button formatted as string]
--> you can script "on mouseUp tBtn"
--> in the widget script or card script or ... (up)
end if
end handler
Moreover to key events:
Craig wrote:Messages seem to be blocked in a widget. Even rawKeyDown.
That's why we have not (yet) keyboard support in LCB. So no key event reaches a widget and thus, from the same logic as for mouse events, no key event can be "forwarded/passed" to LC Script.
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 11:24 am
by Klaus
Thank you for the clarification and explanation!
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 11:35 am
by [-hh]
Klaus wrote:Thank you for the clarification and explanation!
What a praise! By Klaus! But I forgot to remark
A widget is not an ordinary control ... 
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 11:59 am
by Klaus
Hi Hermann,
[-hh] wrote: ↑Wed Sep 19, 2018 11:35 am
Klaus wrote:Thank you for the clarification and explanation!
What a praise! By Klaus!
don't pride yourself on that!
[-hh] wrote: ↑Wed Sep 19, 2018 11:35 am
But I forgot to remark
A widget is not an ordinary control ... 
I NEVER would have doubted this!
Best
Klaus
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 3:22 pm
by dunbarx
Hmmm.
Because these messages ARE "forwarded" to LC Script by the svg-icon-path widget.
mouseDown
mouseUp
mouseDoubleUp
mouseEnter
mouseLeave
no other mouse event.
The SVG widget does indeed respond to a mouseUp handler in the widget script. But the line graph does not. So is there a list of trappable messages for the stock widgets in the tool palette?
Craig
Re: No messages in widgets?
Posted: Wed Sep 19, 2018 3:47 pm
by [-hh]
Craig.
There is no list. One has to look into the source code (lcb-file), I have at the moment no time to do that for all widgets.
Here is the method in case somebody takes the time.
- Go to https://github.com/livecode/livecode/tr ... ns/widgets
or the extensions folder of your app folder (in Contents).
- Open a widget folder
- Open the lcb file with a text editor (in GitHub click raw).
- Search for "OnMouse" (or directly for "post " and "execute script ")
- Look in the found public handler whether there is a line that begins with post "mouse" or "execute script" (containing a LCS mouse handler)
By that you find all mouse events that are "passed".
If there is none, then no mouseEvent is passed, no chance to catch it.
Hermann