LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Sun Oct 18, 2020 5:20 pm
Hi All,
I try to select a menuitem of a popup btn "bMyPopUp" by script
I discover that i can navigate among line of the menu with arrowkeys up and down.
Is there a way to do that by script ?
I tried this (comment lines doesn't work)
Code: Select all
...
click at the loc of btn "bMyPopUp"
send "arrowkey down" to this stack
select item 2 of btn "bMyPopUp"
set the menuhistory of btn "bMyPopUp" to 2
--select menuitem 2 of btn "bMyPopUp"
--arrowkey down
--set the hilite of menuitem 2 of btn "bMyPopUp" to true
...
Best regards
Jean-Marc
https://alternatic.ch
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Sun Oct 18, 2020 6:12 pm
I don't believe it's possible to emulate the visual appearance of a sort of "ghost user" manipulating menu objects.
But you can trigger the script of any menu by dispatching a call to the menuPick handler with the name of the menu item:
Code: Select all
dispatch "menuPick" to btn "Edit" of stack "revMenubar" with "Preferences"
-
richmond62
- Livecode Opensource Backer

- Posts: 10096
- Joined: Fri Feb 19, 2010 10:17 am
Post
by richmond62 » Sun Oct 18, 2020 6:21 pm
FourthWorld wrote: ↑Sun Oct 18, 2020 6:12 pm
I don't believe it's possible to emulate the visual appearance of a sort of "ghost user" manipulating menu objects.
It might be by making a video of a real user manipulating menus and overlaying it on a stack so that it
plays while real menus fire.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Sun Oct 18, 2020 9:44 pm
Jean-Marc.
We have played around with the kludge where under script control you click at the loc of a menu-style button to show the menuItems. But what do you then want the handler to do once that list is visible? Select successive menuItems in turn and have the user "select" one? Would it cycle back to the top if nothing was selected?
Craig
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Sun Oct 18, 2020 10:28 pm
Craig,
Select successive menuItems in turn and have the user "select" one? Would it cycle back to the top if nothing was selected?s fire.
Yes for fun but mainly i want to select a menuitem once the list is visible.
Jean-Marc
https://alternatic.ch
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Mon Oct 19, 2020 3:29 am
Jean-Marc.
Ah. Fun.
So I made two buttons, a pullDown named "B1" and another ordinary button. In the script of the ordinary button:
Code: Select all
on mouseUp
put item 1 of the loc of btn "B1" into x
put item 2 of the loc of btn "B1" into v
answer"Select what?" with "Choice 1" or "Choice 2" or "Choice 3"
click at the loc of btn "B1"
switch it
case "Choice 1"
click at x & "," & v + 20
break
case "Choice 2"
answer "Choice 2"
break
case "Choice 3"
click at x & "," & v + 60
break
end switch
end mouseUp
As expected, the handler opens the menuItems of the pulldown, but that seems to be a blocking condition. Everything stops; no messages are generated with any mouse action. The handler is halted just before the "switch" statement.
If I select "Choice 2" by hand, I get the answer dialog. If I select "Choice 1" by hand, nothing happens, because the menuItem list apparently has already been dismissed, and I am merely clicking on the card. It seems the handler "freezes" until a menuItem is manually clicked, or one clicks somewhere else entirely. At that point the handler continues. So this method does not work.
Craig
Last edited by
dunbarx on Mon Oct 19, 2020 3:47 am, edited 1 time in total.
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Mon Oct 19, 2020 3:39 am
To all.
Is this known and desirable behavior, that, similar to an answer dialog, a currently displayed menuItem list is blocking? Is this an advantage? It does prevent the kludge from working.
Is it an OS thing?
Craig
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Mon Oct 19, 2020 9:31 am
Thanks all for advices
similar to an answer dialog
You're right,
If i put a breakpoint after " click at the loc..." then script editor doesnt open. Same result with dispatch
I used a workaround with a fld. It works but I hoped find an simpler way (for example i need to add a line "Cancel").
There is probabily good reasons to not allow what i try to do (maybe cancel is one).
Richmond:
Video is not an option for me for the same reasons about our "answer dialog" discuss.
Kind regards
Jean-Marc
https://alternatic.ch
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Mon Oct 19, 2020 2:41 pm
Jean-Marc.
I used a workaround with a fld.
You mean you rolled your own, not using a menu-style button at all? Less convenient, but now you are fully in control.
Craig
-
mwieder
- VIP Livecode Opensource Backer

- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
-
Contact:
Post
by mwieder » Tue Oct 20, 2020 2:40 am
Craig-
You're almost there. This will do the trick, although it won't highlight the selected line.
Code: Select all
on mouseUp
local x, v, tChoice
put item 1 of the loc of btn "B1" into x
put item 2 of the loc of btn "B1" into v
answer"Select what?" with "Choice 1" or "Choice 2" or "Choice 3"
put it into tChoice
send "unclick" to me in 1 second
click at the loc of btn "B1"
switch tChoice
case "Choice 1"
put "Choice 1" into msg
break
case "Choice 2"
put "Choice 2" into msg
break
case "Choice 3"
put "Choice 3" into msg
break
end switch
end mouseUp
on unclick
click at the loc of btn "B1"
end unclick
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Tue Oct 20, 2020 3:29 am
Mark.
Hi.
Your handler opens the menu button like mine, but then, like mine, nothing else happens. The handler stops as before; the switch line never fires.
What are you seeing?
Anyway, if a menu-style button is blocking when its menuItem list is displayed, then I think you have to roll your own, using a few other controls that together look like a pullDown, say, but do not block anything. I don't think one aspect of this would be hard to implement, that the user must essentially be prevented from doing anything at all besides either selecting a "menuItem", or clicking somewhere else that does nothing and closes the "menuItem list"
One might call this restriction a "soft" block.
Craig
-
FourthWorld
- VIP Livecode Opensource Backer

- Posts: 10045
- Joined: Sat Apr 08, 2006 7:05 am
-
Contact:
Post
by FourthWorld » Tue Oct 20, 2020 5:21 am
dunbarx wrote: ↑Mon Oct 19, 2020 3:39 am
Is this known and desirable behavior, that, similar to an answer dialog, a currently displayed menuItem list is blocking?
Remember the olden days when menus required holding the mouse button down the whole time?
I suspect what we see today is an offshoot of that, perhaps never augmented with message support because it's so rarely needed.
-
mwieder
- VIP Livecode Opensource Backer

- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
-
Contact:
Post
by mwieder » Tue Oct 20, 2020 8:57 am
Craig-
it depends on what type of menu you're using.
What I wrote there works with a pulldown menu.
The generic case for options and comboboxes as well is more complicated.
-
jmburnod
- VIP Livecode Opensource Backer

- Posts: 2729
- Joined: Sat Dec 22, 2007 5:35 pm
-
Contact:
Post
by jmburnod » Tue Oct 20, 2020 1:39 pm
Thanks All
I was not clear in my first post and title of topic.
I said "select menuitem" but "hilite menuitem" is a better describe.
Here is a stack with work around I use.
Jean-Marc
https://alternatic.ch
-
dunbarx
- VIP Livecode Opensource Backer

- Posts: 10317
- Joined: Wed May 06, 2009 2:28 pm
Post
by dunbarx » Tue Oct 20, 2020 2:23 pm
Mark.
What I wrote there works with a pulldown menu.
I always worked with a pulldown. Your offering opens the menuItem list, and then stops.
What Jean-Marc wanted was, I think:
1- Invoke the handler by, say, clicking on a button.
2- Have the user select an option from the answer dialog.
3- Have the menuItem list open from the pulldown. We have this down solid.
4- Hilite the menuItem the user selected in "2" above.
I have yet to see what Jean-Marc has done with the stack he made. Lets both check it out.
Craig