oMenu:Disable()

oMenu:Disable()

Postby Jeff Barnes » Sat Mar 17, 2007 2:51 am

Hi Everybody,

Here is a strange one for you....

I my app, I create a menu ...

In the example below, I use a logical value to hide a menu choice if I don't want the user to have access to it ... so far so good.

Code: Select all  Expand view
function BuildMenu()
      MENU oMenu

      MENUITEM "Exit"
      MENU
         MENUITEM "Exit Program" Action QuitApp()
      ENDMENU

      MENUITEM "Help" WHEN lHelp       //This is where the issue is
      MENU
         MENUITEM "View Help File"  ACTION ViewHelp()
      ENDMENU

   ENDMENU
return oMenu



Now here is the strange part.....

Lets say lHelp := .t.

If I do a oMenu:Disable() only the menu items that do NOT have the WHEN clause will be disabled.

Why does this happen?


Thanks,
Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Re: oMenu:Disable()

Postby Enrico Maria Giordano » Sat Mar 17, 2007 8:42 am

It seems that WHEN clause has greater priority than Disable() method.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Sat Mar 17, 2007 2:21 pm

Jeff,

>In the example below, I use a logical value to hide a menu choice if I don't want the user to have access to it ... so far so good.

I think it is better to just not to add those items to the menu. I just check user rights when building the menu and leave out those items.

If the items are visible and disabled, the user is left to figure out why they are disabled. They wonder if they will become enabled after some user action, or if they need to configure something. Or, if they do know why the items are disabled, it is like an in-your-face statement that they are not good enough to have access.

If the items aren't on the menu, then both of these issues are solved. This might also solve your other problem.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Jeff Barnes » Sat Mar 17, 2007 4:27 pm

Hi James,

I can see what you are saying and it makes perfect sense, but in this case, having the user "see" what they are missing is a good thing ... additional options that are available to purchase :wink:

Jeff
User avatar
Jeff Barnes
 
Posts: 929
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada

Postby James Bott » Sat Mar 17, 2007 4:50 pm

Jeff,

>I can see what you are saying and it makes perfect sense, but in this case, having the user "see" what they are missing is a good thing ... additional options that are available to purchase.

Ah, a very good point indeed!

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 82 guests