No messages in widgets?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5523
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

No messages in widgets?

Post by dunbarx » Tue Sep 18, 2018 4:45 pm

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

Klaus
Posts: 10325
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: No messages in widgets?

Post by Klaus » Tue Sep 18, 2018 4:57 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5523
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: No messages in widgets?

Post by dunbarx » Tue Sep 18, 2018 6:01 pm

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

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1757
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: No messages in widgets?

Post by [-hh] » Wed Sep 19, 2018 10:38 am

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).
shiftLock happens

Klaus
Posts: 10325
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: No messages in widgets?

Post by Klaus » Wed Sep 19, 2018 10:45 am

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

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1757
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: No messages in widgets?

Post by [-hh] » Wed Sep 19, 2018 10:54 am

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.
shiftLock happens

Klaus
Posts: 10325
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: No messages in widgets?

Post by Klaus » Wed Sep 19, 2018 11:00 am

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)?

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1757
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: No messages in widgets?

Post by [-hh] » Wed Sep 19, 2018 11:12 am

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.
shiftLock happens

Klaus
Posts: 10325
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: No messages in widgets?

Post by Klaus » Wed Sep 19, 2018 11:24 am

Thank you for the clarification and explanation!

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1757
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: No messages in widgets?

Post by [-hh] » Wed Sep 19, 2018 11:35 am

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 ... :-)
shiftLock happens

Klaus
Posts: 10325
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: No messages in widgets?

Post by Klaus » Wed Sep 19, 2018 11:59 am

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! :-D
[-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! 8)


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5523
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: No messages in widgets?

Post by dunbarx » Wed Sep 19, 2018 3:22 pm

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

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1757
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: No messages in widgets?

Post by [-hh] » Wed Sep 19, 2018 3:47 pm

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
shiftLock happens

Post Reply

Return to “Talking LiveCode”