Page 1 of 1

mousedown in the mac menubar

Posted: Sat Apr 21, 2007 12:33 am
by grazer
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

Posted: Sat Apr 21, 2007 12:48 am
by Mark
Hi Grazer,

You probably want to read about the menuPick message in the docs.

Best,

Mark

Posted: Sat Apr 21, 2007 8:38 am
by grazer
>>You probably want to read about the menuPick message in the docs.

I am using the menupick messages. The reason I also use mousedown handlers is to customize the menuitems (enable/disable, checkmarks) each time the user clicks on a menu.

--Grazer[/quote]

Posted: Sat Apr 21, 2007 9:20 am
by Mark
Dear Grazer,

It works fine here. Could you post your script?

Best,

Mark

Posted: Sat Apr 21, 2007 1:16 pm
by 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

Posted: Sat Apr 21, 2007 1:33 pm
by Mark
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):

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
My script would look like:

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
and the button "Allow" would contain a simple script:

Code: Select all

on mouseUp
  menuUpdate
end mouseUp
(These script are just to illistrate my approach, I don't claim they actually work).

Best regards,

Mark