Page 1 of 1

EVT_NOTEBOOK_PAGE_CHANGING: can i change the new page?

Posted: Fri Feb 21, 2020 4:04 pm
by Parduz
I need to "intercept" a page change and "redirect" it to another page (as example, it is changing to page 1 and i want it to land on page 9).

The Page Changing event seemed the right place to do it by using the event->SetSelection, but the wxBookCtrlBase::DoSetSelection ignores the values of the event other than "allowed", so i can't follow that route.

What should be the best way to do this?

Re: EVT_NOTEBOOK_PAGE_CHANGING: can i change the new page?

Posted: Fri Feb 21, 2020 4:21 pm
by PB
Mhm, this looks quite odd to me from the user view point.

Anyway, did you try in the page changing event handler just vetoing the change and then calling wxNotebook::ChangeSelection() with CallAfter()?

Re: EVT_NOTEBOOK_PAGE_CHANGING: can i change the new page?

Posted: Mon Feb 24, 2020 10:26 am
by Parduz
PB wrote:
Fri Feb 21, 2020 4:21 pm
Mhm, this looks quite odd to me from the user view point.

Anyway, did you try in the page changing event handler just vetoing the change and then calling wxNotebook::ChangeSelection() with CallAfter()?
I'm a bit lost, as it seems i'm not able to write a CallAfter() call which compiles.

Code: Select all

CallAfter( [m_MainPages] { m_MainPages->SetSelection(9); } );
gives invalid use of non-static data member (i have a similar call in my code which is working).

Code: Select all

CallAfter( m_MainPages->SetSelection(9) );
gives wxWidgets-3.0.4\include\wx\event.h|1498|error: expression cannot be used as a function|.
How should i write that call?

Re: EVT_NOTEBOOK_PAGE_CHANGING: can i change the new page?

Posted: Mon Feb 24, 2020 10:47 am
by Kvaz1r
It seems that m_MainPages is a member so capture this instead:

Code: Select all

CallAfter( [this] { m_MainPages->SetSelection(9); } );