Page 1 of 1

Can't Connect events

Posted: Thu May 24, 2018 4:47 pm
by greertr
Wondows 10
CodeLite v12.02
WX311
My MinGW distribution ("distro") is x64-native and currently contains GCC 7.3.0 and Boost 1.66.0.
-------------------------
Sorry to have to post this, but I didn't see this issue elsewhere on the forums...I can't connect events because that option doesn't come up on the popup menu when i right click on an element on a dialog in WC.

When I right click on an element like a button on the wc dialog form, there is no option to connect event, where it should appear, is an option to insert a sizer.

Anyone else have this kind of issue, or maybe have a clue what I'm not doing correctly?

thx in adv

Re: Can't Connect events

Posted: Fri May 25, 2018 12:21 am
by DavidGH
Hi,

I think you've been reading http://codelite.org/LiteEditor/WxCrafterHelloWorld. As it was last modified 5 years ago, I fear that page is now misleading.

The standard way to add events for the selected control is from the area that's (by default) at the bottom-left of wxCrafter. See the attached screenshot.

Regards,

David

Re: Can't Connect events

Posted: Fri May 25, 2018 1:53 am
by greertr
thx David, I do see that adding an even from the table does add connect/disconnect code to wxcrafter.cpp.

bearing in mind that I've been away from programming for many years, and am therefore a severe noob at the moment, where would be an appropriate place to add a line of code to give my instruction for what I want the event to do? e.g., change the hidden attribute so that an image becomes visible?

I didn't see a shell that in the code that prompts me to enter my desired action fort the event.

Re: Can't Connect events

Posted: Fri May 25, 2018 1:43 pm
by DavidGH
I'm not sure I understand what you are asking, so I'll give a too-full account of what you should do:

In wxC you select the control to be Connect()ed and select one of the events. I'll use the frame as the control, and wxEVT_MAXIMIZE as an example. In the field to the right of 'wxEVT_MAXIMIZE' you enter a sensible name for the event handler: OnMaximizeEvent. Then, after you finish creating the gui, you click the 'Generate Code' cog icon.

You shouldn't alter the generated code, but if you look at wxcrafter.cpp you'll see the Connect() and Disconnect() have been generated. Similarly wxcrafter.h will now have an eventhandler stub:
virtual void OnMaximizeEvent(wxMaximizeEvent& event) { event.Skip(); }
which won't do anything.

However wxC should also have created code in your derived class, MainFrame in my example. MainFrame.h should now have
virtual void OnMaximizeEvent(wxMaximizeEvent& event);

and MainFrame.cpp:

Code: Select all

void OnMaximizeEvent(wxMaximizeEvent& event)
{
}
which is where to put your code.

Re: Can't Connect events

Posted: Fri May 25, 2018 5:57 pm
by greertr
tyvm David that is what I was looking for.