Accessing menu items outside of frame Topic is solved
-
- In need of some credit
- Posts: 7
- Joined: Fri Jun 15, 2018 4:24 pm
Accessing menu items outside of frame
I am currently trying to access a check menu item initialized on the frame used by wxApp. How does one access it outside of the frame? Trying to store a pointer to the frame (or menubar or menu or menuitem) results in a segmentation fault whenever I access it again even if the pointer works upon storage.
Re: Accessing menu items outside of frame
That should work. Please show where and how you store the pointer and where and how you use it.
Use the source, Luke!
-
- In need of some credit
- Posts: 7
- Joined: Fri Jun 15, 2018 4:24 pm
Re: Accessing menu items outside of frame
Code: Select all
class Control{
MainFrame *frame;
public:
void s(MainFrame *menu);
};
void Control::s(MainFrame *menu){
frame = menu;
frame->GetMenuBar()->Check(ID_ModeChecked, false);
}
bool Control::checkItem(){
return frame->GetMenuBar()->IsChecked(ID_ModeChecked);
}
Re: Accessing menu items outside of frame
That doesn't look like real code, you probably stripped/rewrote a lot. There is nothing special about storing a wxFrame pointer, so there must be an error somewhere which is not in the code you posted.
Just for a test, replace:with:
Just for a test, replace:
Code: Select all
frame->GetMenuBar()->Check(ID_ModeChecked, false);
Code: Select all
wxGetTopLevelParent(this)->GetMenuBar()->Check(ID_ModeChecked, false);
Use the source, Luke!
-
- In need of some credit
- Posts: 7
- Joined: Fri Jun 15, 2018 4:24 pm
Re: Accessing menu items outside of frame
wxGetTopLevelParent worked and showed that im not storing the same pointer (strangely). Trying to store the pointer output of wxGetTopLevelParent results in another unusable pointer causing a segmentation fault. My code is really long at the moment so i stripped it down for the specific problem. I am trying to store settings on a common class not inheriting from any wxWidget class but is called by custom UI elements.
Id package the whole code into a zip file for compilation if it was more convenient to test with
EDIT: it seems that my wxFrame is not reliably giving out information... i will try working out why
Id package the whole code into a zip file for compilation if it was more convenient to test with
EDIT: it seems that my wxFrame is not reliably giving out information... i will try working out why