mousedown in the mac menubar
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
mousedown in the mac menubar
I am an experienced hypercard programmer, but very new to Revolution. I have nearly completed my first software project and am now experimenting with the standalone builder and the menu builder.
When I first moved my menu to the Mac menubar I found that my mousedown handlers in each button didn't work. A quick trip to the documentation revealed that I have to put the mousedown handlers in the group script. OK no big deal. I did it. It still doesn't work.
After a bit of investigation I discovered to my horror that "The Target" does not return the name of the menu button that is being activated, but rather the name of the menubar group.
Am I missing something here? Do I have to write a giant mousedown handler that deals with EVERY menu button each time ANY menu button is clicked?
Thanks, in advance, for your responses,
Grazer
When I first moved my menu to the Mac menubar I found that my mousedown handlers in each button didn't work. A quick trip to the documentation revealed that I have to put the mousedown handlers in the group script. OK no big deal. I did it. It still doesn't work.
After a bit of investigation I discovered to my horror that "The Target" does not return the name of the menu button that is being activated, but rather the name of the menubar group.
Am I missing something here? Do I have to write a giant mousedown handler that deals with EVERY menu button each time ANY menu button is clicked?
Thanks, in advance, for your responses,
Grazer
>>It works fine here. Could you post your script?
on mousedown -- in menubar group script
get the short name of the target
if it is "File" then
--enable and disable File menuitems
else if it is "Edit" then
--enable and disable Edit menuitems
end if
end mousedown
The problem, I think, is that "the target" does not return the name of a menu button.
--Grazer
on mousedown -- in menubar group script
get the short name of the target
if it is "File" then
--enable and disable File menuitems
else if it is "Edit" then
--enable and disable Edit menuitems
end if
end mousedown
The problem, I think, is that "the target" does not return the name of a menu button.
--Grazer
Hi Grazer,
I understand you problem. Indeed, the target is not the menu item but the group.
Usually, I use a different approach. The enabled/disabled of menu items depends on particular conditions. I adjust the menus whenever these conditions change. Rather than a mouseDown handler in the group, I use my own menuUpdate script.
Your script might look like (theoretically):
My script would look like:
and the button "Allow" would contain a simple script:
(These script are just to illistrate my approach, I don't claim they actually work).
Best regards,
Mark
I understand you problem. Indeed, the target is not the menu item but the group.
Usually, I use a different approach. The enabled/disabled of menu items depends on particular conditions. I adjust the menus whenever these conditions change. Rather than a mouseDown handler in the group, I use my own menuUpdate script.
Your script might look like (theoretically):
Code: Select all
on mouseDown
if the hilite of btn "Allow" then
put "Cut/X" into line 3 of btn "Edit" of grp "Menubar 1"
end if
end mouseDown
Code: Select all
on menuUpdate
if the hilite of btn "Allow" then
put "Cut/X" into line 3 of btn "Edit" of grp "Menubar 1"
end if
end menuUpdate
Code: Select all
on mouseUp
menuUpdate
end mouseUp
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode