]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/dialog.cpp
wxSplitPath() bugs corrected and it's documented
[wxWidgets.git] / src / motif / dialog.cpp
index 84712cd4e1cf962806ef53833d3f30da4547d5f7..30b03d55b202409bac1b13d0fa6c218d92d85d05 100644 (file)
@@ -285,26 +285,16 @@ wxDialog::~wxDialog()
     // but I think this should work, if we destroy the children first.
     // Note that this might need to be done for wxFrame also.
     DestroyChildren();
-    
-    // This causes a crash in e.g. the resource sample when closing
-    // the example dialog. TODO: Probably not necessary (?)
-#if 0
-    // Now process all events, because otherwise
-    // this might remain on the screen.
-    Display* display;
-    if (m_mainWidget)
-        display = XtDisplay((Widget) m_mainWidget);
-    else
-        display = (Display*) wxGetDisplay();
-    
-    XSync(display, FALSE);
-    XEvent event;
-    while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) {
-        XFlush(display);
-        XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
-        XtDispatchEvent(&event);
+
+    // The idea about doing it here is that if you have to remove the
+    // XtDestroyWidget from ~wxWindow, at least top-level windows
+    // will still be deleted (and destroy children implicitly).
+    if (GetMainWidget())
+    {
+      DetachWidget(GetMainWidget()); // Removes event handlers
+      XtDestroyWidget((Widget) GetMainWidget());
+      SetMainWidget((WXWidget) NULL);
     }
-#endif
 }
 
 // By default, pressing escape cancels the dialog
@@ -649,9 +639,7 @@ static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent
             
             if (event -> xexpose.count == 0)
             {
-                wxPaintEvent event(win->GetId());
-                event.SetEventObject(win);
-                win->GetEventHandler()->ProcessEvent(event);
+                win->DoPaint();
                 
                 win->ClearUpdateRects();
             }
@@ -699,8 +687,16 @@ static void wxDialogBoxEventHandler (Widget    wid,
                 }
                 else
                 {
-                    keyEvent.SetEventType(wxEVT_CHAR);
-                    dialog->GetEventHandler()->ProcessEvent(keyEvent);
+                    // For simplicity, OnKeyDown is the same as OnChar
+                    // TODO: filter modifier key presses from OnChar
+                    keyEvent.SetEventType(wxEVT_KEY_DOWN);
+
+                    // Only process OnChar if OnKeyDown didn't swallow it
+                    if (!dialog->GetEventHandler()->ProcessEvent (keyEvent))
+                    {
+                        keyEvent.SetEventType(wxEVT_CHAR);
+                        dialog->GetEventHandler()->ProcessEvent(keyEvent);
+                   }
                 }
             }
         }