f



How to show a check mark for a dynamically generated menu item?

Hello,

I am generating a menu dynamically in the #onAboutToDisplayMenu: method 
and would like to add check mark to certain menu items.

The problem is that the #queryCommand: method of my shell is only called
for the menu name itself, but not for each menu item. (See below for my 
coding in those two methods).

How can I enable check marks for the menu items?

Bernhard


queryCommand: aCommandQuery


(aCommandQuery command == #drives) ifTrue: [
	aCommandQuery isEnabled: true. ^true.
].
self halt.
(aCommandQuery command == #toggleDriveMonitoring: )
	ifTrue: [ aCommandQuery checked: true. ^true ].

super queryCommand: aCommandQuery




MyShell>>onAboutToDisplayMenu: aMenu

super onAboutToDisplayMenu: aMenu.
aMenu name == #drives ifTrue: [
	aMenu clear.
	File drives do: [ :eachDrive |
		(aMenu
			addCommand: (MessageSend
				receiver: self
				selector: #toggleDriveMonitoring:
				argument: eachDrive )
			description: eachDrive).
	]
].

-- 
(This email address is only temporarily valid, due to the heavy amount
of spam a post generates. For a permanently valid email address, just
remove all numerical digits from the address.)

0
Bernhard
1/2/2004 4:46:45 AM
comp.lang.smalltalk.dolphin 3769 articles. 0 followers. Post Follow

7 Replies
199 Views

Similar Articles

[PageSpeed] 40

Bernhard Kohlhaas wrote:

> (aCommandQuery command == #toggleDriveMonitoring: )
> ifTrue: [ aCommandQuery checked: true. ^true ].

Try:

     (aCommandQuery command asSymbol == #toggleDriveMonitoring: )

the result of #command is the MessageSend you created in the menu creation
code.

    -- chris


0
Chris
1/2/2004 11:13:57 AM
Chris,

the breakpoint before this statement isn't even reached, so the 
queryCommand: method isn't invoked at all.

Bernhard

Chris Uppal wrote:
> Bernhard Kohlhaas wrote:
> 
> 
>>(aCommandQuery command == #toggleDriveMonitoring: )
>>ifTrue: [ aCommandQuery checked: true. ^true ].
> 
> 
> Try:
> 
>      (aCommandQuery command asSymbol == #toggleDriveMonitoring: )
> 
> the result of #command is the MessageSend you created in the menu creation
> code.
> 
>     -- chris
> 
> 

-- 
(This email address is only temporarily valid, due to the heavy amount
of spam a post generates. For a permanently valid email address, just
remove all numerical digits from the address.)

0
Bernhard
1/2/2004 11:46:29 AM
I wrote:

>      (aCommandQuery command asSymbol == #toggleDriveMonitoring: )

I forgot to mention that CommandQuery>>command can sometimes answer nil.  It's
sporadic, and I've never been able to find a reproducible example, so I don't
know whether it's actually a bug or a feature.  I just put an early #isNil test
into #queryCommand: implementations where I'm using #asSymbol.

    -- chris



0
Chris
1/2/2004 11:46:44 AM
Bernhard,
>
> the breakpoint before this statement isn't even reached, so the
> queryCommand: method isn't invoked at all.

Ah, right.

I think that may be because you are using a MessageSend rather than a Message.

Since MessageSends "know" what their receiver is, the command framework will
try their #queryCommand: before that of the Presenter, and I suspect (without
having worked out the details) that that is what's going wrong for you.

If you use a Message, then the framework will still assume that the intended
receiver of the command is the MVP component and will use your Presenter's
#queryCommand.

    -- chris



0
Chris
1/2/2004 12:00:02 PM
Chris,


> I forgot to mention that CommandQuery>>command can sometimes answer
> nil.  It's sporadic, and I've never been able to find a reproducible
> example, so I don't know whether it's actually a bug or a feature.  I
> just put an early #isNil test into #queryCommand: implementations
> where I'm using #asSymbol.

Just FYI, CommandQuery>>commandSymbol automatically does a nil check for
you.

-- 
Ian

Use the Reply-To address to contact me.
Mail sent to the From address is ignored.

0
Ian
1/2/2004 5:43:20 PM
That was indeed the problem. It works now with a Message instead of a 
MessageSend.

Thanks so much,

Bernhard


Chris Uppal wrote:
> Bernhard,
> 
>>the breakpoint before this statement isn't even reached, so the
>>queryCommand: method isn't invoked at all.
> 
> 
> Ah, right.
> 
> I think that may be because you are using a MessageSend rather than a Message.
> 
> Since MessageSends "know" what their receiver is, the command framework will
> try their #queryCommand: before that of the Presenter, and I suspect (without
> having worked out the details) that that is what's going wrong for you.
> 
> If you use a Message, then the framework will still assume that the intended
> receiver of the command is the MVP component and will use your Presenter's
> #queryCommand.
> 
>     -- chris
> 
> 
> 

-- 
(This email address is only temporarily valid, due to the heavy amount
of spam a post generates. For a permanently valid email address, just
remove all numerical digits from the address.)

0
Bernhard
1/2/2004 9:43:00 PM
Ian,

> Just FYI, CommandQuery>>commandSymbol automatically does a nil check for
> you.

Useful.  Thank you.

    -- chris


0
Chris
1/3/2004 10:22:15 AM
Reply:

Similar Artilces:

CDialog
I've got a simple menu, created it in the resource editor and made it the menu for my main Dialog window. (CRSMDlg) How do I get my menu to display a check / tick box next to the item when I click on it. I tried adding the ON_UPDATE_COMMAND_UI event handler but no matter what I do the menu item is not "ticked" : void CRSMDlg::OnUpdateOps(CCmdUI *pCmdUI) { pCmdUI->SetCheck(1); } Is there an update / repaint method I must call, some property I must set on the Dialog box to inform it ? Also I found that the shortcut keys does not display when you click on...

check marks or dynamic items for run-time shortcut menus
Labview version: 8.0 I'd like to create a run-time shortcut menu for my Xcontrol, that would allow user to toggle between two states of the control. Is it possible to either 1) dynamically apply check marks to run-time shortcut menus or 2) dynamically modify the run-time shortcut menu content Tomi Hi Tomi, Great question.  Yes, you can do what you want with run-time shortcut menus in LabVIEW 8.0.  If you want to dynamically modify the menu content, you have to do it in the "Shortcut Menu Activation?" event in the facade VI of the XControl.  In the e...

Menu - hiding and showing selected menu items using code
Hello -- I need to learn how to name the menu objects so I can - hide or disable them - show/enable them based on the user's role/access permissions or how the user has responded to the always-visible menu choices. Can someone tell me about this or where I can find code examples for doing this? The menu was built with the Menu Editor. The complete main menu items are: File Customer Engineering Financial Maintenance Upon starting the app we want only the File menu to be visible. After the user selects a file to be processed, the other menu choices are to become visible. Thanks for any...

how to add the menu items dynamically into the top level or main menu in vc++(MFC)
Hi All, I have a doubt, Is it possible to load the menu iteams dyamically in the main menu or top level? If possible means please give some idea about that . Thanks in Advance Regards, Mohanaranga ...

Dynamic generation of doc-strings of dynamically generated classes
Hi! I've asked Google, but have not found any useful information there. Situation: I have a base class, say >>> class base(object): ImportantClassAttribute = None Now, I want to dynamically generate subclasses of base. That's not a problem. However, I very much want those subclasses to have individual doc-strings. More precicely, I want that important class attribute to be reflected in the doc-string. That's the problem. The only way I've managed to accomplish that is something like the following. >>> ImportantClassAttribute = 7 >>&g...

Dynamic command on Menu items?
(Python newbie alert..only 1 week's experience) I want to create several menu items based upon a config file. In this config file are label, function and a parameter. I want to show label in the menu, then when it's chosen, call function with the given parameter. How can I do the correct equivalent of the following (which definitely doesn't work)? l='Zooks' f='func' p='Got Zooks' M.menu.add_command(label=l, command=lambda: f(p)) so that when I pick 'Zooks' from the menu, func gets called with 'Got Zooks'. Joe You could do it like this...

Bevelbutton Menu Check Marks
I have been playing with Bevelbuttons and quickly ran into the annoying check mark placed next to the most recent menu item select the next time that menu is shown. No idea why this has been implemented - but I have found a solution (not the solution, but a solution - if there's a better solution please post it. Bascially I kill and rebuild the menu of the bevelbutton every time the button is clicked. Instead of building the menu in the bevelbutton.open I kill it and build it time and time again in bevelbutton.mousedown: me.deleteAllRows me.MenuValue = -1 me.addro...

dynamically changing menu items
How do you dynamically change menu items in TCL/tk? For example if I want to change the command associated with a menu item or the text displayed on it? Mark Tarver wrote: > How do you dynamically change menu items in TCL/tk? > > For example if I want to change the command associated with a menu > item or the text displayed on it? > $menu entryconfigure $index -command "newCommand" -label "newText" http://www.tcl.tk/man/tcl8.4/TkCmd/menu.htm#M62 On 28 Aug, 11:40, Bryan Oakley <oak...@bardo.clearlight.com> wrote: > Mark Tarver wrote: > >...

dynamically create menu items
Hello, I need to develope an awt-based app, which requires a list menuitems are created based on current application model when the Menu to which the list of menuitems are attached is clicked. An actionListener registered to Menu won't be triggered because action event is not fired by Menu. I am wondering if there is a way for me to capture a Menu event and a list of menuitems can be created dynamically? Thanx William ...

A mystic checked menu item
Hi, I have two checked menu items in my program. I use the lines OptionsMenu->Append(OPTION_SOUND,"&Sound","Swith action sounds On/Off", GetConfig()->m_PlaySound); OptionsMenu->Append(OPTION_REGION_PAUSE,"Pause at region end","Allow for actions when finishing a region", GetConfig()->m_RegionPause); EVT_MENU(OPTION_SOUND, MyFrame::OnSound) EVT_MENU(OPTION_REGION_PAUSE, MyFrame::OnPausing) void MyFrame::OnSound(wxCommandEvent& WXUNUSED(event)) { GetConfig()->m_PlaySound = m_menuBar->IsC...

Checking/Unchecking Menu Items?
In article <macdev-23E118.04101729012004@senator-bedfellow.mit.edu>, Miro Jurisic <macdev@meeroh.org> wrote: > > What's the preferred way to Enable/Disable and Check/Uncheck menu items? > > Assign them command IDs and install kEventCommandUpdateStatus event handlers. You're slightly missing the point, Milo, I think. I'm not asking the preferred way to find out if a menu NEEDS to be checked or unchecked, but rather the preferred way to check or uncheck it. Previously (OS9 version of this application) I got the MenuRef from a resource,th...

php dynamic menu generation
Hello, I've got a situation, where i'd like to have a selection box of products. The user picks one product, and a menu appears doesn't activate, but it shows some more detail regarding the product, say a car, and the detail is a list of years you could pick. You pick the year and a list of color choices appears, so on and so forth until you either select a choice in which a database query is generated and you get a page or you get a page listing all close parts. I was wondering if this was feasible without clientside javascript, i don't like to rely on client side scriptin...

Dynamically generated pop-up menu
Hi. I'm trying to create a GUI that reads in a file that contains recordings from several different channels. I then want to plot any one of those channels on a plot in my GUI, and for the user to select which channel to plot via a pop-up menu. Each file has a different number of channels. I've been able to generate a pop-up menu whose items ("String") are the channel names, but I can't figure out a way to write the code for the pop-up menu callback function (i.e. plot the selected channel) since it seems that I have to hardwire the callback code...regardless o...

SET MENU ITEM MARK
Dear All, Happy new year 2004. In a 4D database, I have two processes using the same menu bar. In one process I check one menu item using the "SET MENU ITEM MARK" command and when I go to the other proces I see that the same menu item is checked in this process too. I tried this command both with and without the optional process parameter but in both cases 4D behaves same way. Is it possible to avoid this? Regards, Vahdat Dastpak. ...

Web resources about - How to show a check mark for a dynamically generated menu item? - comp.lang.smalltalk.dolphin

iPhone 5 A6 chip to dynamically up-clock up to 1.3GHz (and downclock too)?
Interesting video from our friends at TLDToday: If this is not just a Geekbench app glitch, it could indicate why that A6 processor is so 2X ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

iPhone 5 Lightning port dynamically reassigns pins
... of Apple's Lightning USB cable shows that the pins on the plug aren't arranged symmetrically, suggesting that the Lightning port can dynamically ...

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 2/2/2016 9:26:17 AM