When I want to Veto(), or do not allow a user to change a page by
asking the user a question (a modal one), I got 2 changing / changed
events (this only append if I use the mouse to select the page in the
listBook). Tested on winXP with gcc 3.4 and MSC 7.1.
Here is a sample :
#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__
#include <wx/wx.h>
#include <wx/listbook.h>
#include <wx/listctrl.h>
class MyFrame : public wxFrame
{
protected:
wxListbook* m_listbook1;
wxPanel* m_panel1;
wxStaticText* m_staticText1;
wxPanel* m_panel2;
wxStaticText* m_staticText2;
wxTextCtrl* m_textLog;
// Virtual event handlers, overide them in your derived class
virtual void OnPageChanged( wxListbookEvent& event );
virtual void OnPageChanging( wxListbookEvent& event );
public:
MyFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const
wxString& title = wxT("TestListBook"), const wxPoint& pos =
wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style
= wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
~MyFrame();
};
class tlbApp : public wxApp
{
public:
virtual bool OnInit()
{
MyFrame* frame = new MyFrame(0L);
frame->SetIcon(wxICON(aaaa)); // To Set App Icon
frame->Show();
return true;
}
};
IMPLEMENT_APP(tlbApp);
MyFrame::MyFrame( wxWindow* parent, wxWindowID id, const wxString&
title, const wxPoint& pos, const wxSize& size, long style ) :
wxFrame( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
m_listbook1 = new wxListbook( this, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxLB_DEFAULT );
m_panel1 = new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer2;
bSizer2 = new wxBoxSizer( wxVERTICAL );
m_staticText1 = new wxStaticText( m_panel1, wxID_ANY, wxT("P1"),
wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1->Wrap( -1 );
bSizer2->Add( m_staticText1, 0, wxALL, 5 );
m_panel1->SetSizer( bSizer2 );
m_panel1->Layout();
bSizer2->Fit( m_panel1 );
m_listbook1->AddPage( m_panel1, wxT("a page"), false );
m_panel2 = new wxPanel( m_listbook1, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer3;
bSizer3 = new wxBoxSizer( wxVERTICAL );
m_staticText2 = new wxStaticText( m_panel2, wxID_ANY, wxT("P2"),
wxDefaultPosition, wxDefaultSize, 0 );
m_staticText2->Wrap( -1 );
bSizer3->Add( m_staticText2, 0, wxALL, 5 );
m_panel2->SetSizer( bSizer3 );
m_panel2->Layout();
bSizer3->Fit( m_panel2 );
m_listbook1->AddPage( m_panel2, wxT("a page"), true );
#ifndef __WXGTK__ // Small icon style not supported in GTK
wxListView* m_listbook1ListView = m_listbook1->GetListView();
long m_listbook1Flags = m_listbook1ListView->GetWindowStyleFlag();
m_listbook1Flags = ( m_listbook1Flags & ~wxLC_ICON ) |
wxLC_SMALL_ICON;
m_listbook1ListView->SetWindowStyleFlag( m_listbook1Flags );
#endif
bSizer1->Add( m_listbook1, 1, wxEXPAND, 5 );
m_textLog = new wxTextCtrl( this, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
bSizer1->Add( m_textLog, 1, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizer1 );
this->Layout();
// Connect Events
m_listbook1->Connect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED,
wxListbookEventHandler( MyFrame::OnPageChanged ), NULL, this );
m_listbook1->Connect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING,
wxListbookEventHandler( MyFrame::OnPageChanging ), NULL, this );
wxLog::SetActiveTarget( new wxLogTextCtrl(m_textLog) );
}
MyFrame::~MyFrame()
{
// Disconnect Events
m_listbook1->Disconnect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED,
wxListbookEventHandler( MyFrame::OnPageChanged ), NULL, this );
m_listbook1->Disconnect( wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING,
wxListbookEventHandler( MyFrame::OnPageChanging ), NULL, this );
}
void MyFrame::OnPageChanging( wxListbookEvent& event )
{
wxLogMessage(_("Changing"));
}
void MyFrame::OnPageChanged( wxListbookEvent& event )
{
wxLogMessage(_("Changed"));
::wxMessageBox(_("Hop"));
m_listbook1->ChangeSelection(1);
}
To give youy more information, the second event is sent when the mouse
is moved. If you click on the page and the mouse is frozen, there is
only 1 event. The second event happen when the user mouve the mouse !
Is it a wxWidgets bug ? a MS Windows one ? a miscomprehension of me ?
--
Jérémie
jf> When I want to Veto(), or do not allow a user to change a page by
jf> asking the user a question (a modal one), I got 2 changing / changed
jf> events (this only append if I use the mouse to select the page in the
jf> listBook). Tested on winXP with gcc 3.4 and MSC 7.1.
Do you see this problem in the notebook sample? It does exactly the same
thing.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Well, the notebook works correctly. So do you think it can be a MSW
bug ?
Thanks for your attention
--
jeremie
jf> On 2 juil, 15:22, Vadim Zeitlin <va...@wxwidgets.org> wrote:
jf> > On Wed, 2 Jul 2008 02:05:04 -0700 (PDT) jeremie fouche <jeremie.fou...@gmail.com> wrote:
jf> >
jf> > jf> When I want to Veto(), or do not allow a user to change a page by
jf> > jf> asking the user a question (a modal one), I got 2 changing / changed
jf> > jf> events (this only append if I use the mouse to select the page in the
jf> > jf> listBook). Tested on winXP with gcc 3.4 and MSC 7.1.
jf> >
jf> > Do you see this problem in the notebook sample? It does exactly the same
jf> > thing.
jf>
jf> Well, the notebook works correctly.
The sample also allows you to use a list book.
Ok, I tested the notebook sample (with wxUSE_LISTBOOK), and the same
problem occurs : 2 times asking if we want to leave the page when we
want to Veto() the event.
--
Jérémie
jf> Ok, I tested the notebook sample (with wxUSE_LISTBOOK), and the same
jf> problem occurs : 2 times asking if we want to leave the page when we
jf> want to Veto() the event.
Indeed, I can see this (if you answer "No" the first time). I don't see
why does it happen though, even after just spending some time debugging
this. It looks like something resets selection to the abandoned selection
but I wasn't able to understand how does it happen.
Of course, looking at this code it is clear that we really need to add a
wxEVT_COMMAND_LIST_ITEM_SELECTING event and react to it in wxListbook as
changing selection and then resetting it back is a bad idea anyhow. But,
still, I'm pretty sure that this worked correctly before so with some svn
archeology skills it should be possible to find when exactly did it stop
working. It would be great if someone had time to do this...
On 3 juil, 04:59, Vadim Zeitlin <va...@wxwidgets.org> wrote:
> On Wed, 2 Jul 2008 07:46:01 -0700 (PDT) jeremie fouche <jeremie.fou...@gmail.com> wrote:
>
> jf> Ok, I tested the notebook sample (with wxUSE_LISTBOOK), and the same
> jf> problem occurs : 2 times asking if we want to leave the page when we
> jf> want to Veto() the event.
>
> Indeed, I can see this (if you answer "No" the first time). I don't see
> why does it happen though, even after just spending some time debugging
> this. It looks like something resets selection to the abandoned selection
> but I wasn't able to understand how does it happen.
Maybe the fact that the second event is sent when the mouse moves
could be a clue :
> To give youy more information, the second event is sent when the mouse
> is moved. If you click on the page and the mouse is frozen, there is
> only 1 event. The second event happen when the user mouve the mouse !
> Of course, looking at this code it is clear that we really need to add a
> wxEVT_COMMAND_LIST_ITEM_SELECTING event and react to it in wxListbook as
> changing selection and then resetting it back is a bad idea anyhow. But,
> still, I'm pretty sure that this worked correctly before so with some svn
> archeology skills it should be possible to find when exactly did it stop
> working. It would be great if someone had time to do this...
I tried with 2.6.4, and the problem still exists.
--
Jérémie
I tried with 2.6.2, and the problem still exists.
--
Jérémie
I tried with 2.6.1, and the problem still exists.
--
Jérémie
chris
> _______________________________________________
> wx-users mailing list
> wx-u...@lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
>
CE> so, the latest build is 2.8.8. 2.6.1 is older and more buggy than 2.6.4
No, no, I asked Jérémie to check if he can find the old build where it did
work so he did exactly the right thing. The problem is that apparently this
is broken since a long time. Or maybe I'm wrong and it never worked at all.
Anyhow, I'll try to look at it again when I have time... in the meanwhile
you (Jérémie) probably should report this on Trac so that it doesn't get
forgotten.
Thanks for your efforts,
Ticket opened (http://trac.wxwidgets.org/ticket/9692)
Looking at the changelog, I think it has always hapened : wxListbook
was created in 2.5.0, and changed in 2.6.2.
I think I could have a look in the 2 next month, but I'm not sure I
could find the problem. I never tried to debug wxWidgets.
Moreover, I didn't tried on wxGTK or wxMAC, because I don't have those
OS.
--
Jérémie
jf> I think I could have a look in the 2 next month, but I'm not sure I
jf> could find the problem. I never tried to debug wxWidgets.
jf> Moreover, I didn't tried on wxGTK or wxMAC, because I don't have those
jf> OS.
The problem is almost certainly MSW-specific... it has something to do
with the focus changes in wxListCtrl but I don't understand what, yet.
Regards,