Changeset 101 for trunk/src


Ignore:
Timestamp:
Jun 14, 2008, 12:44:45 AM (17 years ago)
Author:
lpino
Message:

Changes to try to make popups work

Location:
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Control.java

    r98 r101  
    4747    int drawCount, hCursor;
    4848    int foreground, background;
    49 //@@TODO(dmik)
    5049    Menu menu;
    5150    String toolTipText;
     
    32653264//      * WPARAM.  Otherwise, use WPARAM to find the menu.
    32663265//      */
    3267 //      Shell shell = getShell ();
    3268 //      Menu oldMenu = shell.activeMenu, newMenu = null;
     3266      Shell shell = getShell ();
     3267      Menu oldMenu = shell.activeMenu;
     3268      Menu newMenu = null;
    32693269//      if ((lParam >> 16) == 0) {
    3270 //              newMenu = menuShell ().findMenu (wParam);
     3270              newMenu = menuShell ().findMenu (mp2);
    32713271//      }
    3272 //      Menu menu = newMenu;
    3273 //      while (menu != null && menu != oldMenu) {
    3274 //              menu = menu.getParentMenu ();
    3275 //      }
    3276 //      if (menu == null) {
    3277 //              menu = shell.activeMenu;
    3278 //              while (menu != null) {
    3279 //                      /*
    3280 //                      * It is possible (but unlikely), that application
    3281 //                      * code could have disposed the widget in the hide
    3282 //                      * event.  If this happens, stop searching up the
    3283 //                      * ancestor list because there is no longer a link
    3284 //                      * to follow.
    3285 //                      */
    3286 //                      menu.sendEvent (SWT.Hide);
    3287 //                      if (menu.isDisposed ()) break;
    3288 //                      menu = menu.getParentMenu ();
    3289 //                      Menu ancestor = newMenu;
    3290 //                      while (ancestor != null && ancestor != menu) {
    3291 //                              ancestor = ancestor.getParentMenu ();
    3292 //                      }
    3293 //                      if (ancestor != null) break;
    3294 //              }
    3295 //      }
     3272      Menu menu = newMenu;
     3273      while (menu != null && menu != oldMenu) {
     3274              menu = menu.getParentMenu ();
     3275      }
     3276      if (menu == null) {
     3277             menu = shell.activeMenu;
     3278              while (menu != null) {
     3279                      /*
     3280                      * It is possible (but unlikely), that application
     3281                      * code could have disposed the widget in the hide
     3282                      * event.  If this happens, stop searching up the
     3283                      * ancestor list because there is no longer a link
     3284                      * to follow.
     3285                      */
     3286                      menu.sendEvent (SWT.Hide);
     3287                      if (menu.isDisposed ()) break;
     3288                      menu = menu.getParentMenu ();
     3289                      Menu ancestor = newMenu;
     3290                      while (ancestor != null && ancestor != menu) {
     3291                              ancestor = ancestor.getParentMenu ();
     3292                      }
     3293                      if (ancestor != null) break;
     3294              }
     3295      }
     3296      System.out.println("Control:WM_INITMENU " + menu);
    32963297//
    32973298//      /*
     
    33003301//      * a field to null in a disposed shell is not harmful.
    33013302//      */
    3302 //      if (newMenu != null && newMenu.isDisposed ()) newMenu = null;
    3303 //      shell.activeMenu = newMenu;
     3303      if (newMenu != null && newMenu.isDisposed ())
     3304          newMenu = null;
     3305      shell.activeMenu = newMenu;
    33043306//
    33053307//      /*
    33063308//      * Send the show event
    33073309//      */
    3308 //      if (newMenu != null && newMenu != oldMenu) {
    3309 //              /*
    3310 //              * SWT.Selection events are posted to allow stepping
    3311 //              * in the VA/Java debugger.  SWT.Show events are
    3312 //              * sent to ensure that application event handler
    3313 //              * code runs before the menu is displayed.  This
    3314 //              * means that SWT.Show events would normally occur
    3315 //              * before SWT.Selection events.  While this is not
    3316 //              * strictly incorrect, applications often use the
    3317 //              * SWT.Selection event to update the state of menu
    3318 //              * items and would like the ordering of events to
    3319 //              * be the other way around.
    3320 //              *
    3321 //              * The fix is to run the deferred events before
    3322 //              * the menu is shown.  This means that stepping
    3323 //              * through a selection event that was caused by
    3324 //              * a popup menu will fail in VA/Java.
    3325 //              */
    3326 //              display.runDeferredEvents ();
    3327 //              newMenu.sendEvent (SWT.Show);
    3328 //              // widget could be disposed at this point
    3329 //      }
     3310      if (newMenu != null && newMenu != oldMenu) {
     3311              /*
     3312              * SWT.Selection events are posted to allow stepping
     3313              * in the VA/Java debugger.  SWT.Show events are
     3314              * sent to ensure that application event handler
     3315              * code runs before the menu is displayed.  This
     3316              * means that SWT.Show events would normally occur
     3317              * before SWT.Selection events.  While this is not
     3318              * strictly incorrect, applications often use the
     3319              * SWT.Selection event to update the state of menu
     3320              * items and would like the ordering of events to
     3321              * be the other way around.
     3322              *
     3323              * The fix is to run the deferred events before
     3324              * the menu is shown.  This means that stepping
     3325              * through a selection event that was caused by
     3326              * a popup menu will fail in VA/Java.
     3327              */
     3328              display.runDeferredEvents ();
     3329              newMenu.sendEvent (SWT.Show);
     3330              // widget could be disposed at this point
     3331      }
    33303332      return null;
    33313333}
  • trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/Shell.java

    r98 r101  
    680680    releaseShells ();
    681681    super.releaseWidget ();
    682 //@@TODO(dmik)
    683 //    activeMenu = null;
     682    activeMenu = null;
    684683//    display.clearModal (this);
    685684    display = null;
     
    12501249//      return result;
    12511250//}
    1252 MRESULT WM_CONTEXTMENU (int mp1, int mp2) {
    1253     System.out.println("Shell:WM_CONTEXTMENU - HANDLE = " + Integer.toHexString (handle));
    1254     return MRESULT.TRUE;
    1255 }
    1256 }
     1251//MRESULT WM_CONTEXTMENU (int mp1, int mp2) {
     1252//    System.out.println("Shell:WM_CONTEXTMENU - PARENT HANDLE = " + Integer.toHexString (handle));
     1253//    System.out.println("Control:WM_CONTEXTMENU - MENU HANDLE = " + Integer.toHexString (activeMenu.handle));
     1254//    return MRESULT.TRUE;
     1255//}
     1256}
Note: See TracChangeset for help on using the changeset viewer.