=== modified file 'src/com/goldencode/p2j/ui/client/TopLevelWindow.java' --- src/com/goldencode/p2j/ui/client/TopLevelWindow.java 2016-02-25 06:13:23 +0000 +++ src/com/goldencode/p2j/ui/client/TopLevelWindow.java 2016-03-10 18:10:50 +0000 @@ -35,12 +35,14 @@ ** should be repainted after changing active window, not before. ** 013 HC 20160203 Improved runtime support of KEEP-FRAME-Z-ORDER and TOP-ONLY attributes. ** 014 EVL 20160224 Javadoc fixes to make compatible with Oracle Java 8 for Solaris 10. +** 015 SBI 20160310 Changed to reuse the common code */ package com.goldencode.p2j.ui.client; import java.io.*; import java.util.*; +import java.util.function.Predicate; import com.goldencode.p2j.ui.*; import com.goldencode.p2j.ui.chui.*; @@ -667,19 +669,18 @@ if (mouseSource != null && mouseSource.isDisplayed()) { - WidgetId id = null; - // search for a parent with a valid id - Widget parent = mouseSource; - while (parent != null) + Widget parent = WidgetRegistry.findAncestor(mouseSource, new Predicate() { - id = parent.getId(); - if (id != null) + @Override + public boolean test(Widget t) { - break; + return UiUtils.getWidgetId(t) != null; } - parent = parent.parent(); - } + }); + + WidgetId id = (parent != null) ? parent.getId() : null; + if (id != null) { // not all OS-widgets have an ID, skip those === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java' --- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-03-07 18:00:01 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingMouseHandler.java 2016-03-10 19:44:15 +0000 @@ -18,8 +18,8 @@ ** window. ** 003 HC 20151013 NPE fix. ** 004 HC 20151024 Fixed race condition when dispatching mouse events. -** 005 SBI 20160307 Changed processAction to deliver mouse events to the closest registered widget -** in the source mouse widget parent's hierarchy. +** 005 SBI 20160310 Changed processAction/findMouseSource to deliver mouse events to the closest +** registered widget in the source mouse widget parent's hierarchy. */ package com.goldencode.p2j.ui.client.gui.driver.swing; @@ -37,6 +37,7 @@ import com.goldencode.p2j.ui.WidgetId; import com.goldencode.p2j.ui.client.*; import com.goldencode.p2j.ui.client.event.*; +import com.goldencode.p2j.ui.client.gui.LabelGuiImpl; import com.goldencode.p2j.ui.client.gui.ScrollBarGuiImpl; import com.goldencode.p2j.ui.client.gui.ScrollPaneGuiImpl; import com.goldencode.p2j.ui.client.gui.driver.*; @@ -381,7 +382,35 @@ Widget mouseSource = window.findMouseSource(new MouseEvt(e, window)); - return mouseSource; + // find widget in its ancestor's hierarchy that has an id + Widget parent = WidgetRegistry.findAncestor(mouseSource, new Predicate() + { + @Override + public boolean test(Widget t) + { + // TODO: to improve/simplify the mouse pointer is over a widget + // work around to fix cursor changes over labels + return UiUtils.getWidgetId(t) != null && !(LabelGuiImpl.class.equals(t.getClass())); + } + }); + + // TODO: move this widget-specific logic into methods that are implemented in the widget + // hierarchy so that we do not have direct references to widget classes in this common code + + // if it is scroll bar then find its scroll pane parent + if (parent instanceof ScrollBarGuiImpl) + { + parent = WidgetRegistry.findAncestor(parent, new Predicate() + { + @Override + public boolean test(Widget t) + { + return ScrollPaneGuiImpl.class.equals(t.getClass()); + } + }); + } + + return parent; } /** @@ -421,33 +450,8 @@ return false; } - // find widget in its ancestor's hierarchy that has an id - Widget parent = WidgetRegistry.findAncestor(widget, new Predicate() - { - @Override - public boolean test(Widget t) - { - return UiUtils.getWidgetId(t) != null; - } - }); - - // TODO: move this widget-specific logic into methods that are implemented in the widget - // hierarchy so that we do not have direct references to widget classes in this common code - - // if it is scroll bar then find its scroll pane parent - if (parent instanceof ScrollBarGuiImpl) - { - parent = WidgetRegistry.findAncestor(parent, new Predicate() - { - @Override - public boolean test(Widget t) - { - return ScrollPaneGuiImpl.class.equals(t.getClass()); - } - }); - } - - WidgetId wid = UiUtils.getWidgetId(parent); + + WidgetId wid = UiUtils.getWidgetId(widget); if (wid == null) { === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2016-02-03 21:22:52 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.mouse.js 2016-03-10 19:47:15 +0000 @@ -21,7 +21,7 @@ ** 006 IAS 20160217 LOAD-MOUSE-POINTER ans SET-WAIT-STATE support ** 007 SBI 20151217 Changed to resize the offscreen canvas first and then to blast the offscreen ** image to the original canvas. -** SBI 20160104 Fixed the window location. +** SBI 20160310 Added getEvents() to MouseMovable. */ "use strict"; @@ -923,6 +923,20 @@ removeListeners(win, mops, listeners); }; + this.getEvents = function() + { + var events = {}; + for (var prop in mops) + { + if (mops.hasOwnProperty(prop)) + { + events[prop] = true; + } + } + + return events; + }; + function processMouseDragStop(mThis, mouseOp) { return function(evt)