disappearing dot in menus with radio items

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

disappearing dot in menus with radio items

Post by piotrtrojanowski »

I have a group of radio menu items appended dynamically to my main menu. Every time I get EVT_MENU_OPEN I Destroy each radio item in the group and Append each radio menu item again. During this process, for one of the radio items I call Check to mark it as selected.

It works from the beginning, I can see the dot appearing close to the selected radio item. However the dot disappears after some time, say 10 minutes of using my program. Under debugger I see that a call to Check is executed every time I handle EVT_MENU_OPEN. I even assert that the item I want selected IsChecked() and yes, the assertion is true.

Funny... :)
Piotr
HeReSY
Earned some good credits
Earned some good credits
Posts: 120
Joined: Fri Sep 17, 2004 8:58 pm
Location: Germany

Post by HeReSY »

Don't destroy your items in the menu, when you open it.
In my app i check the style of my listview when i open the menu. Then i only check the item for this style.

HeReSY
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

Post by piotrtrojanowski »

Let me explain the function of my group of radio items.

My app allows displaying multiple top windows. One document is open in one window, similarly to what MS Word does. The main menu has a "Window" menu that lists names of all currently open documents. The list may be different each time user opens "Window" menu.
Piotr
HeReSY
Earned some good credits
Earned some good credits
Posts: 120
Joined: Fri Sep 17, 2004 8:58 pm
Location: Germany

Post by HeReSY »

Why don't you destroy the menu item, when one of your docs closed or changed the name?

HeReSY
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

Post by piotrtrojanowski »

I am sure there are plenty of ways of handling the described scenario. I think the one I implemented is good enough.
Piotr
tan
wxWorld Domination!
wxWorld Domination!
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Re: disappearing dot in menus with radio items

Post by tan »

Hi,
piotrtrojanowski wrote:I have a group of radio menu items appended dynamically to my main menu. Every time I get EVT_MENU_OPEN I Destroy each radio item in the group and Append each radio menu item again. During this process, for one of the radio items I call Check to mark it as selected.

It works from the beginning, I can see the dot appearing close to the selected radio item. However the dot disappears after some time, say 10 minutes of using my program. Under debugger I see that a call to Check is executed every time I handle EVT_MENU_OPEN. I even assert that the item I want selected IsChecked() and yes, the assertion is true.

Funny... :)
I don't sure it will help :) though, did you try to call wxMenu::UpdateUI() after all?
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

Post by piotrtrojanowski »

Yes, I tried this. It doesn't help.
Piotr
Lucky75
Super wx Problem Solver
Super wx Problem Solver
Posts: 305
Joined: Thu May 03, 2007 3:54 pm

Post by Lucky75 »

What happens if you do a call to see if it is checked, and then if it is, manually set the check. You could do this on a timer as a workaround too, but I don't know why it would be doing that.
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

Post by piotrtrojanowski »

Interestingly my current implementation is able to properly set states of all radio menu items: enabled/disabled, by calling wxMenuItem::Enable(). At the same time, in the same place in code, calls to wxMenuItem::Check() do not have any effect.
Piotr
Lucky75
Super wx Problem Solver
Super wx Problem Solver
Posts: 305
Joined: Thu May 03, 2007 3:54 pm

Post by Lucky75 »

Its a menu item your trying to check?

Try this?

Code: Select all

menuPointer->Check(menuitem_id,true);
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

Post by piotrtrojanowski »

I've tried that already. Thx.
Piotr
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

Post by piotrtrojanowski »

I have another group of radio menu items in the main menu. In the case of this group they are created once - at the program startup, as a part of main menu creation.

Interestingly I can make the dot disappear for this group as well.

This eliminates all doubts about correctness of code dealing with dynamic creation of menu items as a cause of the problem.
Piotr
SpeedyX
Earned a small fee
Earned a small fee
Posts: 16
Joined: Thu Jun 14, 2007 4:11 pm
Location: Germany

Post by SpeedyX »

Did you already finda solution for this problem?

I am working with a dynamic submenu. I add or remove radio menu items dynamically to this menu. One of this item should always be activated, but if I activate the last item in this submenu, the dot, that marks the active item, has disappeared.

If you solve this problem, I would appreciate it, if you post the solution ...

Thanks,
Xenia
piotrtrojanowski
Knows some wx things
Knows some wx things
Posts: 34
Joined: Mon Jan 15, 2007 11:53 am

Post by piotrtrojanowski »

No, unfortunately I have not. This is still an open issue.
Piotr
SpeedyX
Earned a small fee
Earned a small fee
Posts: 16
Joined: Thu Jun 14, 2007 4:11 pm
Location: Germany

Post by SpeedyX »

Sorry to hear that. I will analyse this problem furthermore, maybe I will find a solution.
Post Reply