flatnotebook - overriding

BlitzMax Forums/Brucey's Modules/flatnotebook - overriding

plash(Posted 2008) [#1]
I tried not connecting 'wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING' to a function, but when clicking the close button on the current page closes it. Is there a way to stop the page from being removed?

EDIT: or a style to keep a page on the notebook from being removed?


plash(Posted 2008) [#2]
Found it, style flag "wxFNB_NO_X_BUTTON".

works for now :P


DavidDC(Posted 2008) [#3]
For the record, if you did want to override the event, you would have used something like:


Connect(Id,wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING, _OnPageClosing)

Function _OnPageClosing(_event:wxEvent)
	wxFlatNotebookEvent(_event).Veto()
End Function



So it's not that you *don't* connect to an event to stop the system processing it, but rather you *do* connect, and then in that connection Veto() it, or refuse to Skip() it, depending on the event type.


Glenn Dodd(Posted 2008) [#4]
can you give me a laymans description of the difference between veto and skip?


plash(Posted 2008) [#5]
Thanks alot.


DavidDC(Posted 2008) [#6]
If the event type extends wxNotifyEvent or wxCloseEvent, then you should be able to Veto() the event. The call acts as it sounds - prevents the widget from taking the action usually associated with the event.

Skip() is defined in the wxEvent base type and hence can be called from all extending event types. Calling Skip() passes the event on up the hierarchy chain.

For example, connecting to a specific wxMouseEvent (which extends wxEvent) will stop propagation of the event up the window (widget) hierarchy in its tracks *unless* you explicitly call event.Skip() from your connecting function. So if you wanted to stop a right mouse click on a certain widget, you would connect up to the right click wxMouseEvent and refuse to Skip(). That way the widget, which is higher up in the hierarchy chain, will never see the event. Note that in this case you can't Veto() a mouse event since wxMouseEvent extends neither wxNotifyEvent nor wxCloseEvent.

Generally, you Skip() all connected non wxCommandEvents.

Why not forget Veto() and always use Skip()/Non Skip()? My *assumption* is that Veto() is able to stop an event that has already propagated to the control in question. At this point it would be too late to *not* Skip() - the event message has already spread and the action will proceed regardless.


Glenn Dodd(Posted 2008) [#7]
thank you for that explanation.

Cheers
glenn