Page 1 of 1

Help with MENU COMMAND !!

Posted: Sat Jul 31, 2010 7:39 pm
by MdaSolution
i MUSY SHOW A MENUITEM IF oHOME IS TRUE

MENU oMenu POPUP 2007

MENUITEM oHome PROMPT "Home" CHECKED

IF oHome
MENUITEM "Go to Bed"
else
MENUITEM "Work"
endif

ENDMENU
ACTIVATE MENU oMenu AT nRow, nCol OF obtn
RETURN (oMenu)

WHERE IS THE ERROR ?

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 6:39 am
by Jaque Morique
First Error "I MUSY" i think u must write "I MUST"

Second Error "Capital Letters " is crying in a Newsgroup

Third Error "U write with u wrong name" Silvio

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 12:44 pm
by James Bott
The problem is that oHome is the menu object not the variable containg a logical.

MENUITEM oHome PROMPT "Home" CHECKED

There is DATA of the object, lChecked which you can check:

If oHome:lChecked
...
endif

However, I am not sure what you are trying to do. If you are defining the menu item in code as checked then the menuitem you are subsequently defining will always be "Go to bed" so what is the point?

Code: Select all

if oHome:lChecked  // always .t.
   MENUITME "Go to bed"
else
   MENUITEM "Work"
endif
If your idea is to change the next menu item as the user checks and unchecks the previous one, then I'm not sure this can be done, nor would I recommend it. I have never seen a menu item change real-time and I think users would find this very confusing. Better would be to enable and disable both menu items based on the check. There still might be a better design, but without more information about what you are trying to do I can not make any recommendations.

James

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 4:35 pm
by Silvio
Jaque Morique wrote:First Error "I MUSY" i think u must write "I MUST"

Second Error "Capital Letters " is crying in a Newsgroup

Third Error "U write with u wrong name" Silvio

Sorry Sir "Jaque Morique"...

First Error - You are join on this forum Only on 22 April of 2010 and I not understood who U 're

Second Error - Dear Man You wrote on a Forum and not a NewsGroup and I pray you if you want write something don't write something far from the topic

Third Error My names is Silvio when you found the same my name on all messages , When you found MdaSolution I cannot also be Silvio, because can be also another man, and I not know You , None give you the authorization to write in this tone, you're a bad man, how many topic you're write sir?, how many application you saled sir?, how many classes you made Sir?

Dear Antonio Linares ,
I will not allow anyone to offend my name and company to which I belong.

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 5:58 pm
by MdaSolution
Right Silvio.

This man wrote only 15 posts and I never talk to him.


Dear James,
I must set a menu item .t. or .f. and show items on the same menu , Can I use cargo value ?
thanks
Can you help me please and make a smal sample pls ?

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 6:39 pm
by James Bott
Here is a possible solution. I have not tried it.

James

Code: Select all

MENUITEM oHome PROMPT "Home" ;
   CHECKED ACTION SwitchMenu(oHome, oSwitchMenu)
MENUITEM oSwitchMenu PROMPT "Go to Bed"

function SwitchMenu( oHome, oSwitchMenu )
   if oHome:lChecked
      oSwitchMenu:setPrompt("Go to bed")
   else
      oSwitchMenu:setPrompt("Work")
   endif
   oSwitchMenu:refresh()
return nil

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 7:34 pm
by James Bott
Here is a working example.

I still don't like the way this works. The menu is collapsed when the user checks Home. Then the menu is different when they pull it down again. Very confusing.

James

Code: Select all

#include "fivewin.ch"
function main()

   TMyApp():new()

return nil

class TMyApp
   method new()
   method buildMenu()
   method switchMenu()
endclass

method new()
   local oWnd
   DEFINE WINDOW oWnd menu ::buildMenu()
   ACTIVATE WINDOW oWnd
return self

Method buildMenu()
   LOCAL oMenu, oHome, oSwitchMenu
   MENU oMenu
    MENUITEM "&File"
      MENU
         MENUITEM oHome PROMPT "Home" CHECKED ;
             ACTION ::SwitchMenu(oHome,oSwitchMenu)
         MENUITEM oSwitchMenu PROMPT "Go to Bed"
      ENDMENU
   ENDMENU
return oMenu

Method SwitchMenu( oHome, oSwitchMenu )
   if oHome:lChecked
      oSwitchMenu:setPrompt(" Work")
      oHome:setCheck(.f.)
   else
      oSwitchMenu:setPrompt(" Go to bed")
      oHome:setCheck(.t.)
   endif
   oSwitchMenu:refresh()
return nil

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 7:37 pm
by MdaSolution
thanks james but perhap I not explain you good


sample :
Menu omenu
menuItem " define if go home or go out "

If go home
menuitem"read a book" action ...
menuitem"wacth the tv" action...
menuitem"play with pc" action
else
menuitem"dance in Disco" action ...
menuitem"run with my car" action...
menuitem"drink wisky" action ...
endif

menuitem ....
menuitem ...
endmenu



I wish this :

the user when open the menu the first ( clicking on button) see only "define if go home or go out " not checked

and only

menuitem"dance in Disco" action ...
menuitem"run with my car" action...
menuitem"drink wisky" action ...


while if click on "define if go home or go out " and reopen the menu the user see the "define if go home or go out " checked

and these menuitelms :

menuitem"read a book" action ...
menuitem"wacth the tv" action...
menuitem"play with pc" action

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 8:04 pm
by James Bott
Well, you can't use an IF/ELSE during the menu definition that relys on an action that has not yet happened. You will have to just define the variable menu items with whatever, then you will have to change both the prompts and action codeblocks at runtime when the user checks the other item. This can be done basically as I showed in my sample code--you will just have to add more menu items.

If you have an unequal number of menu items (for each group) then you will also have to add or subtract menu items. This could get complicated.

Did you want to use a pulldown menu or a pop-up menu?

Regards,
James

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 8:18 pm
by James Bott
Here is an idea. You use a pulldown menu with three pulldowns. The first is Location, then Home, then Work.

Location
Home
Work

Home
Watch TV
Play with PC

Work
Meeting
Paperwork

When the user selects a location all the items on that pulldown are enabled and all the ones on the other pulldown are disabled. This would be much simpler to code and easier for the user to understand.

James

Re: Help with MENU COMMAND !!

Posted: Sun Aug 01, 2010 10:05 pm
by MdaSolution
james,
I must use it on popup menu
I open it with mouse when i click on specific area or specific button

Re: Help with MENU COMMAND !!

Posted: Mon Aug 02, 2010 4:49 am
by James Bott
You could do the same with a popup menu. Just have three menu choices and two of them have submenus which are enabled and disabled depending on the first menu.

James