wxAuiNotebook: How to allow an event (page changing)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

wxAuiNotebook: How to allow an event (page changing)

Frédéric Bron
Hi,

I am able to handle the page changing event in wxAuiNotebook but then
the page is not changed:

MyBook::MyBook() {
   ...
   Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGING, &MyBook::on_page_change, this);
}

void MyBook::on_page_change(wxAuiNotebookEvent &event) {
  // do something before change
  event.Allow();
}

The event is well catched but then the page is not changed. How do I
say that I want the standard page changing event to be proceessed
normally after my handler is called?

Thanks,

Frédéric

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxAuiNotebook: How to allow an event (page changing)

Frédéric Bron
> I am able to handle the page changing event in wxAuiNotebook but then
> the page is not changed:
>
> void MyBook::on_page_change(wxAuiNotebookEvent &event) {
>   // do something before change
>   event.Allow();
> }

I found that it works if I call event.Skip() instead of event.Allow().
What's the use for event.Allow() and event.Veto() then?

Frédéric

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxAuiNotebook: How to allow an event (page changing)

Kinaou HERVE
Hello Frédéric,

Skip(true/false) lets or not the event to be processed to the other event handlers of the object and its parents.
If you catch the event in several locations, you should explicitly call Skip() to allow the event propagation. Otherwise the event is considered as treated by your method and the propagation is stopped.

Veto()/Allow() is an additional option which allows or not the operation to be performed.
For example, if you call Veto during wxEVT_AUINOTEBOOK_PAGE_CLOSE event, the related page will not be closed.


Regards,

KH

Le jeudi 9 mars 2017 19:21:33 UTC+1, Frédéric Bron a écrit :
> I am able to handle the page changing event in wxAuiNotebook but then
> the page is not changed:
>
> void MyBook::on_page_change(wxAuiNotebookEvent &event) {
>   // do something before change
>   event.Allow();
> }

I found that it works if I call event.Skip() instead of event.Allow().
What's the use for event.Allow() and event.Veto() then?

Frédéric

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
 
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: wxAuiNotebook: How to allow an event (page changing)

Frédéric Bron
> Veto()/Allow() is an additional option which allows or not the operation to
> be performed.
> For example, if you call Veto during wxEVT_AUINOTEBOOK_PAGE_CLOSE event, the
> related page will not be closed.

But apparently, if I just no call Skip() in PAGE_CHANGING, the page is
also not closed. This is why I wonder if Veto() is useful.
It seems to me that this is not the normal behavior which should be:
1. event PAGE_CHANGING
2. event PAGE_CLOSE

Apparently if I capture PAGE_CHANGING and do not call Skip(),
PAGE_CLOSE event does not happen. Is this the normal behavior?
Maybe PAGE_CLOSE is called by PAGE_CHANGING which would explain this.

Frédéric

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re[2]: wxAuiNotebook: How to allow an event (page changing)

Vadim Zeitlin-4
On Sat, 11 Mar 2017 06:48:06 +0100 Frédéric Bron wrote:

FB> > Veto()/Allow() is an additional option which allows or not the operation to
FB> > be performed.
FB> > For example, if you call Veto during wxEVT_AUINOTEBOOK_PAGE_CLOSE event, the
FB> > related page will not be closed.
FB>
FB> But apparently, if I just no call Skip() in PAGE_CHANGING, the page is
FB> also not closed.

 I'm confused here: are we speaking about PAGE_CHANG{ING,ED} event pair or
PAGE_CLOSE{,D} one?

FB> This is why I wonder if Veto() is useful.

 For the events inheriting from the standard wxNotifyEvent, the logic is
simple: in most cases, the action corresponding to the ACTION-ING event is
allowed by default and you need to call Veto() in your handler to prevent
it from happening. There are a few cases in which the event is disallowed
by default (e.g. label editing in tree/list controls), in this case you
need to call Allow() in your handler to let it happen. In any case, after
the action happens, you get the ACTION-ED event.

 AUI PAGE_CLOSE{,D} events unfortunately don't follow the standard naming
convention, but they do seem to follow the same semantics. In particular,
whether you call Skip() or not in PAGE_CLOSE handler shouldn't change
anything, as the event is allowed by default.

 Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re[2]: wxAuiNotebook: How to allow an event (page changing)

Frédéric Bron
My fault, I was talking only about PAGE_CHANGING/CHANGED, I was
confused by another post.

Here is a code snippet with some comments:

class MyNotebook : public wxAuiNotebook {
 private:
  void on_page_change(wxAuiNotebookEvent &event) {
    // check something
    // if all following lines are commented -> no page change happen
    //event.Skip(); // this line alone uncommented -> page change
happen correctly
    //event.Allow(); // this line alone uncommented -> no page change happen
    //event.Veto(); // this line alone uncommented -> no page change happen
  }

 public:
  MyNotebook(wxWindow *parent)
      : wxAuiNotebook(parent, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxAUI_NB_TOP | wxAUI_NB_TAB_SPLIT |
                                               wxAUI_NB_SCROLL_BUTTONS) {
  AddPage(new Page(this), "Page1", false);
  AddPage(new Page(this), "Page2", false);
  Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGING, &MyNotebook::on_page_change, this);
  }
};

So again, my question: it seems to me that Skip() is all what we need here:
- do not call Skip() -> page is not changed,
- call Skip() -> the page is changed.

Then the question: are Allow() and Veto() useful?

>  For the events inheriting from the standard wxNotifyEvent, the logic is
> simple: in most cases, the action corresponding to the ACTION-ING event is
> allowed by default and you need to call Veto() in your handler to prevent
> it from happening.

If this were right, the page would change if I would call none of
Skip/Allow/Veto in ACTION-ING.
This is why it seems to me that there is a bug here: no Skipping
ACTION-ING should not prevent ACTION-ED to happen. Am I right?

Frédéric

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re[4]: wxAuiNotebook: How to allow an event (page changing)

Vadim Zeitlin-4
On Sun, 12 Mar 2017 07:55:45 +0100 Frédéric Bron wrote:

FB> My fault, I was talking only about PAGE_CHANGING/CHANGED, I was
FB> confused by another post.
FB>
FB> Here is a code snippet with some comments:
FB>
FB> class MyNotebook : public wxAuiNotebook {
FB>  private:
FB>   void on_page_change(wxAuiNotebookEvent &event) {

 Ugh, this is really confusing: this handler should be called
on_page_changing() as it's connected to wxEVT_AUINOTEBOOK_PAGE_CHANGING
event and not wxEVT_AUINOTEBOOK_PAGE_CHANGED one...

FB>     // check something
FB>     // if all following lines are commented -> no page change happen
FB>     //event.Skip(); // this line alone uncommented -> page change happen correctly
FB>     //event.Allow(); // this line alone uncommented -> no page change happen

 But, indeed, all the comments above seem to indicate a bug.

FB>     //event.Veto(); // this line alone uncommented -> no page change happen

 This one is expected, of course.

FB> This is why it seems to me that there is a bug here: no Skipping
FB> ACTION-ING should not prevent ACTION-ED to happen. Am I right?

 Generally speaking, definitely yes. I hope this applies to wxAUI too, but
it does have quite a few exceptions to normal wxWidgets rules, so I'm not
100% sure. Ideal would be to have a(n as small as possible) patch to the
aui sample reproducing the problem: if you can make one, I'd be able to
easily debug it there and see what's really going on.

 Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/

attachment0 (203 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re[4]: wxAuiNotebook: How to allow an event (page changing)

Frédéric Bron
Hi,

Here is a minimal sample showing the issue.

Frédéric

--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wx-users

aui-bug.cpp (1K) Download Attachment
Loading...