Broken handling of EVT_UPDATE_UI (Issue #23150)

19 views
Skip to first unread message

oneeyeman1

unread,
Jan 18, 2023, 3:20:12 AM1/18/23
to wx-...@googlegroups.com, Subscribed

Description

Platform and version information

  • wxWidgets version <!-- latest release
  • wxWidgets port <!-- wxMSW
  • OS <!-- Windows 8.1 with MSVC 2017.
  • GTK version:
  • Which GDK backend is used:
  • Current theme:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23150@github.com>

oneeyeman1

unread,
Jan 18, 2023, 3:31:42 AM1/18/23
to wx-...@googlegroups.com, Subscribed

Description

I am writing an MDI based application.
In the MDIParentFrame I create a "managed" toolbar.
When I the MDIChildFrame is created I also create an "unmanaged" toolbar with the parent of MDIParentFrame. In the child frame view I add EVT_UPDATE_UI events. However, those events never arrive.
There is a simple workaround - call SetToolbar() on the childframe. However, only one toolbar can be managed.
In the OnInternalIdle() function, there is a check for GetToolbar(), and the events are sent only when it succeeds.

Platform and version information

  • wxWidgets version you use:
  • wxWidgets port you use:
  • OS and its version:
  • GTK version:
  • Which GDK <!-- [X1<!--

IMPORTANT NOTE

Please note that this entry field uses Markdown, which means that you
need to escape any code snippets pasted here using fenced code blocks,
i.e. by putting ``` before and after it. Also escape, using
backslash, i.e. \< any angle brackets to prevent them from being
interpreted as HTML tags.

Use the Preview tab to review your issue before submitting it to verify that
your formatting is correct.


Describe the bug:
A clear and concise description of what the bug is.

Expected vs observed behaviour:
Please describe what you expected to happen and what actually happens. Make
sure to explain what exactly is the problem, just attaching a screenshot is
not always sufficient. When in doubt, please provide more details rather
than too few.

Patch or snippet allowing to reproduce the problem:
Please attach the smallest possible patch allowing to reproduce the problem
in a sample. If there is absolutely no appropriate sample, please attach a
minimal self-contained example in a single file.

Skip this step if the problem can be reproduced in one of the samples
without any changes.

To Reproduce:
Steps to reproduce the behaviour, please make them as detailed as possible.
For example:

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See error
    -->

Description

I am writing an MDI based application.
In the MDIParentFrame I create a "managed" toolbar.
When I the MDIChildFrame is created I also create an "unmanaged" toolbar with the parent of MDIParentFrame. In the child frame view I add EVT_UPDATE_UI events. However, those events never arrive.
There is a simple workaround - call SetToolbar() on the childframe. However, only one toolbar can be managed.
In the OnInternalIdle() function, there is a check for GetToolbar(), and the events are sent only when it succeeds.

Platform and version information

  • wxWidgets version you use:
  • wxWidgets port you use:
  • OS and its version:
    • GTK version:
    • Which GDK backend is used:
    • Current theme:
      1 or Wayland] --> backend is used:
    • Current theme:


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23150/1386669812@github.com>

    oneeyeman1

    unread,
    Jan 18, 2023, 3:32:38 AM1/18/23
    to wx-...@googlegroups.com, Subscribed

    I'll try to make patch to mdi sample showing the problem in the next couple of days.


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23150/1386670889@github.com>

    VZ

    unread,
    Jan 18, 2023, 9:07:30 AM1/18/23
    to wx-...@googlegroups.com, Subscribed

    I'd just like to note that all GitHub text zones have a "Preview" tab and that it would be great if you could use it to avoid the completely broken markup, mixing up your text with the comments from the original placeholder, as above. For now it would be nice if you could at least edit the first comment above and remove all the junk from it and/or delete it entirely and move its contents into the description, where it should have been from the very beginning.


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23150/1387130169@github.com>

    oneeyeman1

    unread,
    Jan 22, 2023, 3:25:12 AM1/22/23
    to wx-...@googlegroups.com, Subscribed

    As promised, here is the patch to the sample that shows the problem.
    I also included a workaround that makes it work.

    diff -bru docview/view.cpp /c/wxWidgets/samples/docview/view.cpp
    --- docview/view.cpp 2022-12-25 11:47:20.706171600 -0600
    +++ /c/wxWidgets/samples/docview/view.cpp 2023-01-22 02:14:41.735526900 -0600
    @@ -22,9 +22,13 @@
    #endif

    #include "docview.h"
    +#include "wx/docmdi.h"
    +#include "wx/artprov.h"
    #include "doc.h"
    #include "view.h"

    +#define MYID 10001
    +
    // ----------------------------------------------------------------------------
    // DrawingView implementation
    // ----------------------------------------------------------------------------
    @@ -33,21 +37,25 @@

    wxBEGIN_EVENT_TABLE(DrawingView, wxView)
    EVT_MENU(wxID_CUT, DrawingView::OnCut)

    • EVT_UPDATE_UI(MYID, DrawingView::OnUpdateUI)
      wxEND_EVENT_TABLE()

    // What to do when a view is created. Creates actual
    // windows for displaying the view.
    bool DrawingView::OnCreate(wxDocument *doc, long flags)
    {

    • flag = true;
      if ( !wxView::OnCreate(doc, flags) )
      return false;

      MyApp& app = wxGetApp();

    • wxFrame* frame = nullptr;
      if ( app.GetMode() != MyApp::Mode_Single )
      {
      // create a new window and canvas inside it

    •    wxFrame* frame = app.CreateChildFrame(this, true);
      
    •    frame = app.CreateChildFrame(this, true);
         wxASSERT(frame == GetFrame());
      
    •    frame->SetSize( 50, 50, 100, 100 );
         m_canvas = new MyCanvas(this);
         frame->Show();
      
      }
      @@ -61,7 +69,10 @@
      doc->GetCommandProcessor()->SetEditMenu(app.GetMainWindowEditMenu());
      doc->GetCommandProcessor()->Initialize();
      }
    • auto toolbar = new wxToolBar( wxStaticCast( wxTheApp->GetTopWindow(), wxDocMDIParentFrame )->GetClientWindow(), wxID_ANY, wxDefaultPosition, wxDefaultSize );
    • toolbar->AddTool( MYID, "Check", wxArtProvider::GetBitmapBundle( wxART_FLOPPY ) );
    • toolbar->Realize();
      +// frame->SetToolBar( toolbar ); // workaround - uncomment to mae it work
      return true;
      }

    @@ -114,7 +125,7 @@
    {
    m_canvas->ClearBackground();
    m_canvas->ResetView();

    •    m_canvas = nullptr;
      
    •    m_canvas = NULL;
      
         if (GetFrame())
             wxStaticCast(GetFrame(), wxFrame)->SetTitle(wxTheApp->GetAppDisplayName());
      

    @@ -124,7 +135,7 @@
    if ( deleteWindow )
    {
    GetFrame()->Destroy();

    •        SetFrame(nullptr);
      
    •        SetFrame(NULL);
         }
      
      }
      return true;
      @@ -137,6 +148,14 @@
      doc->GetCommandProcessor()->Submit(new DrawingRemoveSegmentCommand(doc));
      }

    +void DrawingView::OnUpdateUI(wxUpdateUIEvent &event)
    +{

    • if( flag )
    •    event.Enable( false );
      
    • else
    •    event.Enable( true );
      

    +}
    +
    @@ -66,18 +66,18 @@
    class DrawingView : public wxView
    {
    public:
    DrawingView() : wxView(), m_canvas(NULL) {}

    virtual bool OnCreate(wxDocument *doc, long flags) wxOVERRIDE;
    virtual void OnDraw(wxDC *dc) wxOVERRIDE;
    virtual void OnUpdate(wxView *sender, wxObject *hint = NULL) wxOVERRIDE;
    virtual bool OnClose(bool deleteWindow = true) wxOVERRIDE;
    
    • void OnUpdateUI(wxUpdateUIEvent &event);
      DrawingDocument* GetDocument();

    private:
    void OnCut(wxCommandEvent& event);

    • bool flag;
      MyCanvas *m_canvas;

      wxDECLARE_EVENT_TABLE();


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23150/1399428984@github.com>

    VZ

    unread,
    Jan 25, 2023, 8:40:20 AM1/25/23
    to wx-...@googlegroups.com, Subscribed

    Replaced by #23166.


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/23150/1403637329@github.com>

    VZ

    unread,
    Jan 25, 2023, 8:40:21 AM1/25/23
    to wx-...@googlegroups.com, Subscribed

    Closed #23150 as completed.


    Reply to this email directly, view it on GitHub, or unsubscribe.

    You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issue/23150/issue_event/8354873128@github.com>

    Reply all
    Reply to author
    Forward
    0 new messages