Problem with Ribbonbar

Post here wxCrafter related issues / features / bugs
Haio
CodeLite Curious
Posts: 4
Joined: Sun Mar 29, 2015 10:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Problem with Ribbonbar

Post by Haio »

Hello.

I have a question about the wxRibbonbar.

I have a "RibbonButtonBar" with three "RibbonButtons".

For these three "RibbonButtons" I had added the "Ribbonbutton_clicked" events.

I tested the events with a simple test: show a messagebox with different content. "A", "B", "C".

Code: Select all

void amsHauptfenster::OnARibbonbuttonClicked(wxRibbonButtonBarEvent& event)
{
	wxMessageBox( "A", "A" );
}

void amsHauptfenster::OnBRibbonbuttonClicked(wxRibbonButtonBarEvent& event)
{
	wxMessageBox( "B", "B" );
}

void amsHauptfenster::OnCRibbonbuttonClicked(wxRibbonButtonBarEvent& event)
{
	wxMessageBox( "C", "C" );
}
But if I click now on Button "A", I get always the messagebox with "C".
In other words: It doesn't matter which button I click, it always use the last added event --> That is currently the event with "C".
How can I fix that? Or what did I make wrong?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem with Ribbonbar

Post by eranif »

Haio wrote:But if I click now on Button "A", I get always the messagebox with "C".
In other words: It doesn't matter which button I click, it always use the last added event --> That is currently the event with "C".
How can I fix that? Or what did I make wrong?
The problem with the wxRibbonButtonBar's button is that they are not a real widgets. i.e. the events are not connected directly to the button
instead, the event is connected to its parent "wxRibbonButtonBar". In such cases, the "Window ID" matters

In your case, I am guessing that all three buttons have "Window ID" of "wxID_ANY" (which means: -1)

To fix this, just type random names, such as:
ID_BUTTON_1, ID_BUTTON_2 and ID_BUTTON_3
wxCrafter will generate enum with these names and the buttons will be identified correctly

Make sure that you have the setting "Generate Window ID" set to "True" (see attached screenshots)
Capture2.PNG
Capture.PNG
NOTE: The same problem exists with normal and wxAUI toolbars: i.e. you need to assign each tool a unique ID

Eran
You do not have the required permissions to view the files attached to this post.
Make sure you have read the HOW TO POST thread
Haio
CodeLite Curious
Posts: 4
Joined: Sun Mar 29, 2015 10:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem with Ribbonbar

Post by Haio »

Thank you, eranif. It works great. ;-)
Haio
CodeLite Curious
Posts: 4
Joined: Sun Mar 29, 2015 10:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem with Ribbonbar

Post by Haio »

Hello.

I have another question/problem with the Ribbonbar.

I added pictures (png files) as icons for my Ribbonbar. The big one for the RibbonbuttonbarButtons works fine.
But the smaller one for the page does not work. It won't be shown.

Image
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem with Ribbonbar

Post by eranif »

Haio wrote:I have another question/problem with the Ribbonbar.
I suspect that it is not related to wxCrafter. Did you try the wxRibbon demo (that comes with wxWidgets)

Eran
Make sure you have read the HOW TO POST thread
Post Reply