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!
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 ?
...
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
...
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.
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?
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.
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.
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
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
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"
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.
Richard Gaskin LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
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.
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.
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.