mousedown in the mac menubar

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
grazer
Posts: 3
Joined: Fri Feb 23, 2007 8:52 pm
Location: Vermont

mousedown in the mac menubar

Post by grazer » Sat Apr 21, 2007 12:33 am

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Apr 21, 2007 12:48 am

Hi Grazer,

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

Best,

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

grazer
Posts: 3
Joined: Fri Feb 23, 2007 8:52 pm
Location: Vermont

Post by grazer » Sat Apr 21, 2007 8:38 am

>>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]

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Apr 21, 2007 9:20 am

Dear Grazer,

It works fine here. Could you post your script?

Best,

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

grazer
Posts: 3
Joined: Fri Feb 23, 2007 8:52 pm
Location: Vermont

Post by grazer » Sat Apr 21, 2007 1:16 pm

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

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Apr 21, 2007 1:33 pm

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

Post Reply

Return to “Mac OS”