Project

General

Profile

issue6013-final-14.03.2022.diff

Vladimir Tsichevski, 03/14/2022 10:59 AM

Download (161 KB)

View differences:

src/com/goldencode/p2j/ui/chui/ThinClient.java 2022-03-13 18:36:16 +0000
2784 2784
**     HC  20220228          Prevented client abend when error in loading image data.
2785 2785
**     CA  20220304          In putBrowseColumnValues, log if attempting to use a BROWSE column with an invalid
2786 2786
**                           ID (set to -1).
2787
**     VVT 20220306          Method processProgressEvent: results of calls to event.id(), and event.source() extracted
2788
**                           to local variables (otherwise these calls are performed >40 times in the method code).
2787 2789
**     SBI 20220311          openMimeResource should accept spaces and escaped spaces for local file resources.
2788 2790
*/
2789 2791

  
......
19582 19584
    */
19583 19585
   public void processProgressEvent(Event event)
19584 19586
   {
19587
      int evtId = event.id();
19588
      Widget eventSource = event.source();
19589
      
19585 19590
      if (event instanceof ResourceEvent)
19586 19591
      {
19587 19592
         ResourceEvent revt = (ResourceEvent) event;
19588 19593
         
19589
         int evtId = revt.id();
19590 19594
         long resourceId = revt.resourceId();
19591 19595
         boolean foundGo = false;
19592 19596
         if (checkBreak(resourceId, evtId))
......
19599 19603
         boolean consume = false;
19600 19604
         try
19601 19605
         {
19602
            TriggerResult tr = invokeTriggers(event.source(), resourceId, evtId, false);
19606
            TriggerResult tr = invokeTriggers(eventSource, resourceId, evtId, false);
19603 19607
            consume = tr.consume;
19604 19608
         }
19605 19609
         finally
......
19626 19630
         }
19627 19631

  
19628 19632
         boolean comEvent = srv.getName().equals("COM-EVENT");
19629
         Runnable serverCode = () -> invokeOnServer(() -> server.invokeServerEvent(srv.id()));
19633
         Runnable serverCode = () -> invokeOnServer(() -> server.invokeServerEvent(evtId));
19630 19634
         
19631 19635
         if (comEvent)
19632 19636
         {
......
19644 19648
      {
19645 19649
         MouseEvt evt = (MouseEvt) event;
19646 19650
         
19651
         MouseEvent awtEvent = evt.getEvent();
19652
         int eventType = awtEvent.getID();
19647 19653
         if (consumeNextMouseClick)
19648 19654
         {
19649 19655
            // this flag is set only on a mouse released event.  only the next clicked event must be consumed.
19650
            int evtID = evt.getEvent().getID();
19651
            if (evtID == MouseEvt.MOUSE_PRESSED  || 
19652
                evtID == MouseEvt.MOUSE_RELEASED ||
19653
                evtID == MouseEvt.MOUSE_CLICKED)
19656
            if (eventType == MouseEvt.MOUSE_PRESSED  || 
19657
                eventType == MouseEvt.MOUSE_RELEASED ||
19658
                eventType == MouseEvt.MOUSE_CLICKED)
19654 19659
            {
19655 19660
               consumeNextMouseClick = false;
19656 19661

  
19657
               if (evtID == MouseEvt.MOUSE_CLICKED)
19662
               if (eventType == MouseEvt.MOUSE_CLICKED)
19658 19663
               {
19659 19664
                  // consume this - it will be raised explicitly
19660 19665
                  evt.consume();
......
19663 19668
            }
19664 19669
         }
19665 19670
         
19666
         Function<Widget, Boolean> hasWindow = (w) ->
19671
         // apply the event
19672
         TopLevelWindow window = (TopLevelWindow) eventSource;
19673
         
19674
         Function<Widget, Boolean> hasWindow = w ->
19667 19675
         {
19668 19676
            if (w != null)
19669 19677
            {
......
19678 19686
            return true;
19679 19687
         };
19680 19688
         
19681
         // apply the event
19682
         TopLevelWindow window = (TopLevelWindow) evt.source();
19683
         
19684 19689
         if (!hasWindow.apply(window))
19685 19690
         {
19686 19691
            // the window has been destroyed
19687 19692
            return;
19688 19693
         }
19689 19694

  
19690
         Widget<?> mouseSource = evt.getExplicitSource();
19691

  
19692
         if (mouseSource == null)
19693
         {
19694
            mouseSource = window.findMouseSource(evt);
19695
         }
19696

  
19695
         // Note: we effectively ignore the value provided by the driver here,
19696
         // to restore using driver events, replace window.findMouseSource(evt) back
19697
         // to evt.getExplicitSource()
19698
         Widget<?> mouseSource = window.findMouseSource(evt);
19699
       
19697 19700
         if (mouseSource == null)
19698 19701
         {
19699 19702
            mouseSource = window;
......
19750 19753
         boolean maySwitchFocusDown = false;
19751 19754
         boolean maySwitchFocusUp = false;
19752 19755
         
19753
         // get the mouse event type
19754
         int evtID = evt.getEvent().getID();
19755 19756
         // exclude mouse move events from consideration
19756
         if (evtID == MouseEvt.MOUSE_PRESSED  ||
19757
             evtID == MouseEvt.MOUSE_RELEASED ||
19758
             evtID == MouseEvt.MOUSE_CLICKED)
19757
         if (eventType == MouseEvt.MOUSE_PRESSED  ||
19758
             eventType == MouseEvt.MOUSE_RELEASED ||
19759
             eventType == MouseEvt.MOUSE_CLICKED)
19759 19760
         {
19760 19761
            maySwitchFocusDown = mouseSource != null &&
19761
                                 evtID == MouseEvt.MOUSE_PRESSED &&
19762
                                 eventType == MouseEvt.MOUSE_PRESSED &&
19762 19763
                                 mouseSource.maySwitchFocus();
19763 19764
            maySwitchFocusUp   = mouseSource != null &&
19764
                                 evtID == MouseEvt.MOUSE_RELEASED &&
19765
                                 eventType == MouseEvt.MOUSE_RELEASED &&
19765 19766
                                 mouseSource.maySwitchFocus();
19766 19767
            
19767 19768
            if (mouseSource != null && !mouseSource.isRMBEntrySupported())
......
19776 19777
         // from here on, we need to work with the browse
19777 19778
         if (legacyMouseSource != null && legacyMouseSource.parent(Browse.class) != null)
19778 19779
         {
19779
            if (!isChui() && (evtID == MouseEvt.MOUSE_CLICKED ||
19780
                              evtID == MouseEvt.MOUSE_PRESSED ||
19781
                              evtID == MouseEvt.MOUSE_RELEASED))
19780
            if (!isChui() && (eventType == MouseEvt.MOUSE_CLICKED ||
19781
                              eventType == MouseEvt.MOUSE_PRESSED ||
19782
                              eventType == MouseEvt.MOUSE_RELEASED))
19782 19783
            {
19783 19784
               // GUI browse click case.
19784 19785
               if (legacyMouseSource instanceof FillIn ||
19785 19786
                   legacyMouseSource instanceof ComboBox)
19786 19787
               {
19787 19788
                  // BrowseColumn is the legacyMouseSource
19788
                  legacyMouseSource = legacyMouseSource.getTriggerWidget(evtID, evt.isRealKey());
19789
                  legacyMouseSource = legacyMouseSource.getTriggerWidget(eventType, evt.isRealKey());
19789 19790
               }
19790 19791
               else if (legacyMouseSource instanceof ToggleBox)
19791 19792
               {
......
19800 19801
                  else
19801 19802
                  {
19802 19803
                     // BrowseColumn is the legacyMouseSource
19803
                     legacyMouseSource = legacyMouseSource.getTriggerWidget(evtID, evt.isRealKey());
19804
                     legacyMouseSource = legacyMouseSource.getTriggerWidget(eventType, evt.isRealKey());
19804 19805
                  }
19805 19806
               }
19806 19807
               else if (!mouseSource.raiseLegacyMouseEvents())
......
19810 19811
               else if (legacyMouseSource instanceof BrowseColumn)
19811 19812
               {
19812 19813
                  BrowseGuiImpl browse = (BrowseGuiImpl) legacyMouseSource.parent(Browse.class);
19813
                  if (evtID == MouseEvt.MOUSE_PRESSED ||
19814
                      evtID == MouseEvt.MOUSE_RELEASED ||
19814
                  if (eventType == MouseEvt.MOUSE_PRESSED ||
19815
                      eventType == MouseEvt.MOUSE_RELEASED ||
19815 19816
                      !evt.isLeftButton() ||
19816 19817
                      ((BrowseColumn) legacyMouseSource).config().readOnly ||
19817
                      browse.isBelowLastRow(evt.getEvent()))
19818
                      browse.isBelowLastRow(awtEvent))
19818 19819
                  {
19819 19820
                     legacyMouseSource = browse;
19820 19821
                  }
......
19830 19831
               legacyMouseSource = legacyMouseSource.parent(Browse.class);
19831 19832
            }
19832 19833
         }
19833
         else if (legacyMouseSource instanceof BrowseGuiImpl && evtID == MouseEvt.MOUSE_CLICKED)
19834
         else if (legacyMouseSource instanceof BrowseGuiImpl && eventType == MouseEvt.MOUSE_CLICKED)
19834 19835
         {
19835 19836
            // If we click on the empty area to the right of the rightmost column which is an editing column,
19836 19837
            // editing is started and the trigger for this rightmost column is invoked.
......
19940 19941
         
19941 19942
         if (evt.isLeftButton())
19942 19943
         {
19943
            if (evtID == MouseEvt.MOUSE_PRESSED)
19944
            if (eventType == MouseEvt.MOUSE_PRESSED)
19944 19945
            {
19945 19946
               downMouseButtonNewFocus = newFocus;
19946 19947
               downMouseButtonOldFocus = oldFocus;
19947 19948
            }
19948
            else if (evtID == MouseEvt.MOUSE_RELEASED)
19949
            else if (eventType == MouseEvt.MOUSE_RELEASED)
19949 19950
            {
19950 19951
               if (downMouseButtonNewFocus != null && !downMouseButtonNewFocus.hasFocus())
19951 19952
               {
......
20106 20107
      if (event instanceof PortableMouseEvent || event instanceof WindowEvent)
20107 20108
      {
20108 20109
         // set the event details
20109
         int evtId = event.id();
20110
         
20111 20110
         functionKey = event instanceof WindowEvent ? ((WindowEvent) event).getAction()
20112 20111
                                                    : ((PortableMouseEvent) event).getAction();
20113 20112
         
20114
         Widget<?> src = event.source();
20113
         Widget<?> src = eventSource;
20115 20114
         
20116 20115
         WidgetId id = src.getId();
20117
         if (src != null && id != null && WidgetId.virtualWidget(id))
20116
         if (id != null && WidgetId.virtualWidget(id))
20118 20117
         {
20119 20118
            // virtual widgets do not call mouse triggers
20120 20119
         }
......
20147 20146
            
20148 20147
            lastKeyState = 0;
20149 20148

  
20150
            TriggerResult tr = invokeTriggers(event.source(), evtId, false, eventX, eventY);
20149
            TriggerResult tr = invokeTriggers(eventSource, evtId, false, eventX, eventY);
20151 20150
            boolean consumed = tr.consume;
20152 20151
            if (functionKey != -1 && functionKey != evtId)
20153 20152
            {
20154
               tr = invokeTriggers(event.source(), functionKey, false, eventX, eventY);
20153
               tr = invokeTriggers(eventSource, functionKey, false, eventX, eventY);
20155 20154
               consumed = consumed || tr.consume;
20156 20155
            }
20157 20156
            
......
20162 20161
            }
20163 20162

  
20164 20163
            // check if we have mouse event attached exit conditions
20165
            if (checkBreak(event.source(), evtId, false) ||
20166
                (functionKey != -1 && checkBreak(event.source(), functionKey, false)))
20164
            if (checkBreak(eventSource, evtId, false) ||
20165
                (functionKey != -1 && checkBreak(eventSource, functionKey, false)))
20167 20166
            {
20168 20167
               addGoPending();
20169 20168
            }
......
20180 20179
      
20181 20180
      if (event instanceof WindowActivated)
20182 20181
      {
20183
         event.source().processEvent(event);
20182
         eventSource.processEvent(event);
20184 20183
         return;
20185 20184
      }
20186 20185

  
20187 20186
      // direct manipulation events calls the handler from source
20188 20187
      if (event instanceof DirectManipulationEvent)
20189 20188
      {
20190
         boolean invokeBefore = event.id() == Keyboard.SE_END_MOVE;
20189
         boolean invokeBefore = evtId == Keyboard.SE_END_MOVE;
20191 20190
         if (invokeBefore)
20192 20191
         {
20193 20192
            // for buttons invoke immediately
20194
            event.source().processDirectManipulationEvent((DirectManipulationEvent)event);
20193
            eventSource.processDirectManipulationEvent((DirectManipulationEvent)event);
20195 20194
         }
20196 20195
         
20197 20196
         // execute registered triggers first
20198
         TriggerResult tr = invokeTriggers(event.source(), event.id(), false);
20197
         TriggerResult tr = invokeTriggers(eventSource, evtId, false);
20199 20198
         
20200 20199
         Integer aliasId = ((DirectManipulationEvent) event).getAlias();
20201 20200
         if (!tr.executed && aliasId != null)
20202 20201
         {
20203
            tr = invokeTriggers(event.source(), aliasId, false);
20202
            tr = invokeTriggers(eventSource, aliasId, false);
20204 20203
         }
20205 20204
         
20206 20205
         if (!invokeBefore)
......
20208 20207
            // if not consumed then invoke event handler
20209 20208
            if (!tr.consume)
20210 20209
            {
20211
               event.source().processDirectManipulationEvent((DirectManipulationEvent)event);
20210
               eventSource.processDirectManipulationEvent((DirectManipulationEvent)event);
20212 20211
            }
20213 20212
            // if consumed(NO-APPLY defined) inform handler about consumed event
20214 20213
            else if (((DirectManipulationEvent)event).hasHandler())
20215 20214
            {
20216
               ((DirectManipulationEvent)event).getHandler().setNoApplyEvent(event.id());
20215
               ((DirectManipulationEvent)event).getHandler().setNoApplyEvent(evtId);
20217 20216
            }
20218 20217
         }
20219 20218
         return;
20220 20219
      }
20221 20220
      
20222 20221
      KeyInput evt    = (event instanceof KeyInput ? (KeyInput) event : null);
20223
      Widget   src    = event.source().getTriggerWidget();
20222
      Widget   src    = eventSource.getTriggerWidget();
20224 20223
      int      key      = (evt == null ? KeyInput.CHAR_UNDEFINED : evt.keyCode());
20225 20224
      int      keyState = (evt == null ? 0 : evt.getKeyState());
20226 20225
      int      action   = (evt == null ? KeyInput.CHAR_UNDEFINED  : evt.actionCode());
src/com/goldencode/p2j/ui/client/TopLevelWindow.java 2022-03-09 23:24:54 +0000
65 65
**                  See #6013.
66 66
**     VVT 20220215 Change 13474 for #6013 temporary reverted (caused multiple regressions,
67 67
**                  need to be completed).
68
**     VVT 20220306 A new private field mousePressedSource was introduced. This field remembers the widget
69
**                  the mouse was pressed upon, and the value is used as the mouse event target during drag
70
**                  operation. findMouseSource(MouseEvt) implementation added. It uses
71
**                  mousePressedSource for drag operations, otherwise calls
72
**                  findMouseSource(evtID, mousePoint). See #6013.
68 73
*/
69 74
/*
70 75
** This program is free software: you can redistribute it and/or modify
......
127 132
import com.goldencode.p2j.ui.*;
128 133
import com.goldencode.p2j.ui.chui.*;
129 134
import com.goldencode.p2j.ui.client.event.*;
130
import com.goldencode.p2j.ui.client.event.FocusEvent;
131 135
import com.goldencode.p2j.ui.client.gui.*;
132 136
import com.goldencode.p2j.ui.client.gui.driver.*;
133 137
import com.goldencode.p2j.ui.client.gui.theme.*;
......
215 219
   }
216 220
   
217 221
   /**
218
    * Get the title bar widget associated witn this window.
222
    * Get the title bar widget associated with this window.
219 223
    * 
220 224
    * @return   See above.
221 225
    */
226
   @SuppressWarnings("static-method")
222 227
   public WindowTitleBar getTitleBar()
223 228
   {
224 229
      return null;
225 230
   }
226 231

  
227 232
   /**
233
    * Find the widget to which the given mouse event can be applied.
234
    * 
235
    * @param    evt
236
    *           The mouse event.
237
    * 
238
    * @return   A widget over which the mouse is positioned or {@code null} if none found.
239
    */
240
   public final Widget<O> findMouseSource(MouseEvt evt)
241
   {
242
      int evtID = evt.getEvent().getID();
243
      java.awt.Point p = evt.getEvent().getPoint();
244
      Widget<O> mouseSource = findMouseSource(evtID, new NativePoint(p.x, p.y));
245
      return (mouseSource == null ? this : mouseSource);
246
   }
247

  
248
   /**
228 249
    * Sets the default window icon for all new windows on the client side.
229 250
    * 
230 251
    * @param    type
......
652 673
    *
653 674
    * @return   <code>TRUE</code> if operation successful <code>FALSE</code> otherwise.
654 675
    */
676
   @SuppressWarnings("static-method")
655 677
   public boolean setWindowIcon(byte[] newIcon)
656 678
   {
657 679
      // this is generic and CHUI version returning false
......
668 690
    *
669 691
    * @return   <code>TRUE</code> if operation successful <code>FALSE</code> otherwise.
670 692
    */
693
   @SuppressWarnings("static-method")
671 694
   public boolean setWindowIcon(boolean small, byte[] newIcon)
672 695
   {
673 696
      // this is generic and CHUI version returning false
......
684 707
    *
685 708
    * @return   <code>TRUE</code> if operation successful <code>FALSE</code> otherwise.
686 709
    */
710
   @SuppressWarnings("static-method")
687 711
   public boolean loadWindowIcon(boolean small, String name)
688 712
   {
689 713
      // this is generic and CHUI version returning false
......
705 729
    * 
706 730
    * @return   This implementation always returns <code>false</code>.
707 731
    */
732
   @SuppressWarnings("static-method")
708 733
   public boolean isMaximized()
709 734
   {
710 735
      return false;
......
715 740
    *
716 741
    * @return   If minimized returns <code>true</code>, <code>false</code> otherwise.
717 742
    */
743
   @SuppressWarnings("static-method")
718 744
   public boolean isMinimized()
719 745
   {
720 746
      return false;
src/com/goldencode/p2j/ui/client/UiUtils.java 2022-03-13 18:35:35 +0000
425 425
    * @param    w
426 426
    *           Component to for which ID is requested.
427 427
    * 
428
    * @return   The widget ID or {@code null} if the widget doesn't have a config.
428
    * @return   The widget ID or {@code null}.
429 429
    */
430 430
   public static WidgetId getWidgetId(Widget<?> w)
431 431
   {
......
438 438
    * @param    widget
439 439
    *           Component to for which ID is requested.
440 440
    * 
441
    * @return   The widget ID or -1 if the widget doesn't have a config.
441
    * @return   The widget ID or -1 if widget is {@code null}
442 442
    */
443 443
   static public int getWidgetIdAsInt(Widget<?> widget)
444 444
   {
src/com/goldencode/p2j/ui/client/WindowManager.java 2022-03-13 18:36:38 +0000
2 2
** Module   : WindowManager.java
3 3
** Abstract :
4 4
**
5
** Copyright (c) 2010-2021, Golden Code Development Corporation.
5
** Copyright (c) 2010-2022, Golden Code Development Corporation.
6 6
**
7 7
** -#- -I- --Date-- ---------------------------------Description----------------------------------
8 8
** 001 SIY 20100629 Created initial version
......
127 127
**                  have a caret, be highlighted, etc.
128 128
**     SVL 20220209 Generate frame LEAVE event when another window receives the focus.
129 129
**     VVT 20220218 Javadocs and other cosmetic fixes.
130
**     VVT 20220306 getNextActiveWindow code refactored, so compilator complains of "Unlikely argument type"
131
**                  no more. processWindowEvent: the mouse source stored with the event by the driver
132
**                  used instead of running window.findMouseSource(evt) second time.  Note: after this
133
**                  change, the call to findMouseSource is executed only once by the driver (previously
134
**                  findMouseSource was called multiple times during the event dispatching and processing,
135
**                  which is waste of CPU time, and probably may result in incorrect returned value).
136
**                  Local variable parent renamed to mouseSourceWithId, since the old name was misleading.
137
**                  See #6013.
130 138
**     EVL 20220309 Dialog box window should ensure the focus to be requested for activation case.
131 139
*/
132 140
/*
......
215 223
   private static final ContextLocal<WorkArea> work = 
216 224
   new ContextLocal<WorkArea>()
217 225
   {
226
      @Override
218 227
      protected synchronized WorkArea initialValue()
219 228
      {
220 229
         return new WorkArea();
......
1259 1268
         }
1260 1269
         
1261 1270
         Map<GuiWindow, Set<TopLevelWindow>> delayed = wa.delayedMinimizeWindows;
1262
         delayed.remove(window);
1271
         delayed.remove((Object)window);
1263 1272
         for (Set<TopLevelWindow> v : delayed.values())
1264 1273
         {
1265 1274
            v.remove(window);
......
1812 1821
   {
1813 1822
      Predicate<TitledWindow<?>> checkNextWindow = tw ->
1814 1823
      {
1815
         if (!tw.isVisible()                               ||
1816
             !(tw instanceof GuiWindow)                    ||
1817
             ((GuiWindow) tw).isShareActivationWithOwner() ||
1818
             ((GuiWindow) tw).isMinimized()                ||
1819
             tw.equals(hidingWindow))
1824
         if (!tw.isVisible() || !(tw instanceof GuiWindow))
1820 1825
         {
1821 1826
            return false;
1822 1827
         }
1823 1828
         
1824
         return true;
1829
         GuiWindow guiWindow = (GuiWindow) tw;
1830
         
1831
         return !guiWindow.isShareActivationWithOwner() &&
1832
                !guiWindow.isMinimized()                &&
1833
                !guiWindow.equals(hidingWindow);
1825 1834
      };
1835
      
1826 1836
      if (!isIconifying)
1827 1837
      {
1828 1838
         ArrayList<Window<?>> list = work.get().currentWindowsStack;
......
1915 1925
      {
1916 1926
         MouseEvt evt = (MouseEvt) event;
1917 1927
         
1918
         Widget<?> mouseSource = (Widget<?>) evt.getExplicitSource();
1919
         if (mouseSource == null)
1920
         {
1921
            mouseSource = window.findMouseSource(evt);
1922
         }
1928
         Widget<?> mouseSource = evt.getExplicitSource();
1923 1929
         
1924 1930
         if (mouseSource != null && mouseSource.isDisplayed())
1925 1931
         {
1926 1932
            // search for a parent with a valid id
1927
            Widget<?> parent = WidgetRegistry.findAncestor(mouseSource,
1933
            Widget<?> mouseSourceWithId = WidgetRegistry.findAncestor(mouseSource,
1928 1934
                                                           t -> UiUtils.getWidgetId(t) != null);
1929 1935
            
1930
            WidgetId id = (parent != null) ? parent.getId() : null;
1936
            WidgetId id = (mouseSourceWithId != null) ? mouseSourceWithId.getId() : null;
1931 1937
            
1932
            if (id != null && parent.ancestor() != null)
1938
            if (id != null && mouseSourceWithId.ancestor() != null)
1933 1939
            {
1934 1940
               // not all OS-widgets have an ID, skip those
1935 1941
               GuiDriver gd = (GuiDriver) OutputManager.getDriver();
1936 1942
               
1937
               gd.selectWindow(parent.topLevelWindow().getId().asInt());
1943
               gd.selectWindow(mouseSourceWithId.topLevelWindow().getId().asInt());
1938 1944
               try
1939 1945
               {
1940 1946
                  gd.handleMouseEvent(id.asInt(), evt.getEvent());
src/com/goldencode/p2j/ui/client/gui/BrowseGuiImpl.java 2022-03-10 10:33:31 +0000
203 203
**     VVT 20220218 Missing @Override annotations added and other cosmetic fixes.
204 204
**     HC  20220304 OFF-END is triggered for additional events: arrow down, pg down, mouse wheel,
205 205
**                  scroll.
206
**     VVT 20220307 findMouseSource(w.findMouseSource(eventID, NativePoint)) overridden to assure the mouse
207
**                  pressed and mouse release events are sent to the same widget. See #6013-152. Also
208
**                  multiple cosmetic fixes.
206 209
*/
207 210

  
208 211
/*
......
262 265

  
263 266
import java.awt.event.*;
264 267
import java.util.*;
265
import java.util.logging.*;
266 268

  
267 269
import com.goldencode.p2j.ui.*;
268 270
import com.goldencode.p2j.ui.chui.*;
......
367 369
   /** Template of a sorting number image name. */
368 370
   private static final String SORT_NUMBER_IMAGE_NAME_TEMPLATE = "sort-num-%d";
369 371

  
370
   /** Logger. */
371
   private static final Logger LOG = LogHelper.getLogger(BrowseGuiImpl.class);
372

  
373 372
   /**
374 373
    * When the current row is out of the view below, then if we press UP key, the new current row
375 374
    * becomes <code>max(1, DOWN - UP_KEY_BOTTOM_OFFSET_ROWS)</code>th row in the viewport
......
909 908
    *
910 909
    * @return attribute container for the given cell.
911 910
    */
912
   public GuiCellAttributes getCellAttr(BrowseRow[] rowCache, int viewportIndex, int columnOrdinal)
911
   public static GuiCellAttributes getCellAttr(BrowseRow[] rowCache, int viewportIndex, int columnOrdinal)
913 912
   {
914 913
      if (rowCache == null || viewportIndex >= rowCache.length)
915 914
      {
......
1338 1337
   @Override
1339 1338
   public void drawCaret()
1340 1339
   {
1341

  
1340
      // no-op
1342 1341
   }
1343 1342

  
1344 1343
   /**
......
1586 1585
      // row resize messages first
1587 1586
      if (id == Keyboard.SE_START_ROW_RESIZE)
1588 1587
      {
1588
         // no-op
1589 1589
      }
1590 1590
      else if (id == Keyboard.SE_END_ROW_RESIZE)
1591 1591
      {
......
1701 1701
               break;
1702 1702
            }
1703 1703

  
1704
            BrowseColumnConfig c = column.config();
1705 1704
            int newWidth = (int) (availableWidth * ((double) dataWidth / totalDataWidth));
1706 1705
            column.setWidth(Math.max(cc.widthFromNative(newWidth), minWidth));
1707 1706
            totalWidth += column.physicalDimension().width;
......
1737 1736
            {
1738 1737
               BrowseColumnGuiImpl column = getColumn(i);
1739 1738
               column.config().selectable = brc.selectable;
1740
               ((GuiDriver) screen().getDriver()).registerDirectManipulation(column);
1739
               ((GuiDriver) OutputManager.getDriver()).registerDirectManipulation(column);
1741 1740
            }
1742 1741
         }
1743 1742
      }
......
1806 1805
      {
1807 1806
         return -1;
1808 1807
      }
1809
      else
1810
      {
1811
         return y / (getRowHeight() + BORDER_THICKNESS);
1812
      }
1808
      
1809
      return y / (getRowHeight() + BORDER_THICKNESS);
1813 1810
   }
1814 1811

  
1815 1812
   /**
......
2643 2640
         {
2644 2641
            return gd.getSysColor(SysColor.COLOR_3DFACE);
2645 2642
         }
2646
         else
2647
         {
2648
            GuiColorResolver browseResolver = getBrowseColorResolver();
2649
            return fg ? browseResolver.fgColor : browseResolver.bgColor;
2650
         }
2651
      }
2652
      else
2653
      {
2654
         return fg ? ColorManager.getFgColor(window, color) :
2655
               ColorManager.getBgColor(window, color);
2656
      }
2643
         
2644
         GuiColorResolver browseResolver = getBrowseColorResolver();
2645
         return fg ? browseResolver.fgColor : browseResolver.bgColor;
2646
      }
2647
      
2648
      return fg ? ColorManager.getFgColor(window, color) :
2649
            ColorManager.getBgColor(window, color);
2657 2650
   }
2658 2651

  
2659 2652
   /**
......
2688 2681
   {
2689 2682
      draggedColumn = column;
2690 2683
      this.leftDragColumnMouseOffset = leftDragColumnMouseOffset;
2684
      MouseHandler.startDragMode();
2691 2685
   }
2692 2686

  
2693 2687
   /**
......
2766 2760
                              (visibleColumnIndex < config.numLockedColumns ? 0 :
2767 2761
                                 resizedColumn.parent().physicalLocation().x);
2768 2762
      leftResizeColumnOffset = Math.max(columnLeftEdge, browseLeftEdge);
2763
      MouseHandler.startDragMode();
2769 2764
   }
2770 2765

  
2771 2766
   /**
......
2959 2954
      {
2960 2955
         return FontManager.resolveFont(window(), labelFont, gd);
2961 2956
      }
2962
      else
2963
      {
2964
         return getBrowseFont();
2965
      }
2957
      
2958
      return getBrowseFont();
2966 2959
   }
2967 2960

  
2968 2961
   /**
......
3380 3373
               FillIn fillIn = (FillIn) editor;
3381 3374
               if (mouseFocusGained)
3382 3375
               {
3383
                  fillIn.config().selectionStart = FillInConfig.INVALID_SELECTION;
3384
                  fillIn.config().selectionEnd = FillInConfig.INVALID_SELECTION;
3376
                  fillIn.config().selectionStart = ControlConfig.INVALID_SELECTION;
3377
                  fillIn.config().selectionEnd = ControlConfig.INVALID_SELECTION;
3385 3378
                  fillIn.setCursorOffset(0);
3386 3379
                  fillIn.setZapMode(false);
3387 3380
               }
......
3821 3814
   }
3822 3815

  
3823 3816
   /**
3824
    * Checks if the browse scrollbar with the given orientation is visible.
3825
    *
3826
    * @param orientation
3827
    *        Scrollbar orientation: vertical or horizontal.
3828
    *
3829
    * @return <code>true</code> the browse scrollbar with the given orientation is visible.
3830
    */
3831
   private boolean isScrollBarVisible(ScrollBar.Orientation orientation)
3832
   {
3833
      ScrollBarGuiImpl bar;
3834
      boolean visible = false;
3835

  
3836
      if (scrollPane != null)
3837
      {
3838
         bar = scrollPane.getScrollBar(orientation);
3839
         if (bar != null)
3840
         {
3841
            visible = bar.isVisible();
3842
         }
3843
      }
3844

  
3845
      return visible;
3846
   }
3847

  
3848
   /**
3849 3817
    * This functions contains the common code for showing/hiding the line of the column filter
3850 3818
    * entry fields.
3851 3819
    */
......
4613 4581
      {
4614 4582
         return calcImplicitRowHeight();
4615 4583
      }
4616
      else
4617
      {
4618
         return calcExplicitRowHeight();
4619
      }
4584
      
4585
      return calcExplicitRowHeight();
4620 4586
   }
4621 4587

  
4622 4588
   /**
......
4971 4937
    *
4972 4938
    * @return <code>true</code> if CTRL key was held down when a mouse button was pressed.
4973 4939
    */
4974
   boolean isCtrlModifier(MouseEvent e)
4940
   static boolean isCtrlModifier(MouseEvent e)
4975 4941
   {
4976
      return (e.getModifiers()   & MouseEvent.CTRL_MASK)      != 0 ||
4977
             (e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
4942
      return (e.getModifiers()   & InputEvent.CTRL_MASK)      != 0 ||
4943
             (e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0;
4978 4944
   }
4979 4945
   
4980 4946
   /**
......
5385 5351
    *
5386 5352
    * @return <code>true</code> if SHIFT key was held down when a mouse button was pressed.
5387 5353
    */
5388
   private boolean isShiftModifier(MouseEvent e)
5354
   private static boolean isShiftModifier(MouseEvent e)
5389 5355
   {
5390
      return (e.getModifiers()   & MouseEvent.SHIFT_MASK)      != 0 ||
5391
             (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0;
5356
      return (e.getModifiers()   & InputEvent.SHIFT_MASK)      != 0 ||
5357
             (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
5392 5358
   }
5393 5359

  
5394 5360
   /**
......
6366 6332
    * @param destIndex
6367 6333
    *        0-based position to which the element is moved.
6368 6334
    */
6369
   private void moveColumnInArray(Object[] array, int srcIndex, int destIndex)
6335
   private static void moveColumnInArray(Object[] array, int srcIndex, int destIndex)
6370 6336
   {
6371 6337
      if (array == null)
6372 6338
      {
......
6638 6604
      }
6639 6605
      else if (isEditorToggleBox())
6640 6606
      {
6607
         // no-op
6641 6608
      }
6642 6609
      else
6643 6610
      {
......
6808 6775
    */
6809 6776
   private class HorizontalColumnScroller
6810 6777
   extends ScrollBarControllerGuiImpl
6811
   implements ScrollBarController
6812 6778
   {
6813 6779
      /**
6814 6780
       * Get maximum value for the scroll bar.
......
6881 6847

  
6882 6848
            return 0;
6883 6849
         }
6884
         else
6885
         {
6886
            return offset;
6887
         }
6850
         
6851
         return offset;
6888 6852
      }
6889 6853

  
6890 6854
      /**
......
6919 6883

  
6920 6884
         int availSize = scrollBar.getTravelSize() - getThumbSize();
6921 6885
         int tPos = Coordinate.toInt(Coordinate.scale(
6922
               (double) availSize * (double) getPosition() / (double) getMax()));
6886
               (double) availSize * (double) getPosition() / getMax()));
6923 6887
         tPos = Math.max(0, tPos);
6924 6888
         tPos = Math.min(tPos, availSize);
6925 6889
         return tPos;
......
7040 7004

  
7041 7005
            int position = availSize > 0 ?
7042 7006
                              Coordinate.toInt(Coordinate.scale(
7043
                                    (double) dragPos * (double) getMax() / (double) availSize)) :
7007
                                    (double) dragPos * (double) getMax() / availSize)) :
7044 7008
                              0;
7045 7009

  
7046 7010
            positionUpdated(position, ScrollStep.CUSTOM, true);
......
7148 7112
            {
7149 7113
               return;
7150 7114
            }
7151
            else
7115
            
7116
            int pageSize = getPageSize();
7117
            if (ScrollStep.LONG.equals(scrollStep))
7152 7118
            {
7153
               int pageSize = getPageSize();
7154
               if (ScrollStep.LONG.equals(scrollStep))
7155
               {
7156
                  if (position < oldPosition)
7157
                  {
7158
                     position = oldPosition - pageSize;
7159
                  }
7160
                  else
7161
                  {
7162
                     position = oldPosition + pageSize;
7163
                  }
7164
               }
7119
               if (position < oldPosition)
7120
               {
7121
                  position = oldPosition - pageSize;
7122
               }
7123
               else
7124
               {
7125
                  position = oldPosition + pageSize;
7126
               }
7127
            }
7165 7128

  
7166
               position += pageSize;
7167
               scrollToRow(position, false, false, drag, true, true, pageSize, false);
7168
            }
7129
            position += pageSize;
7130
            scrollToRow(position, false, false, drag, true, true, pageSize, false);
7169 7131
         }
7170 7132
         else
7171 7133
         {
......
7246 7208
            int firstExistingRow = getFirstExistingRow();
7247 7209
            return firstExistingRow == -1 ? 0 : firstExistingRow;
7248 7210
         }
7249
         else
7250
         {
7251
            return Math.max(0, config.maxDataGuess - getDown());
7252
         }
7211
         
7212
         return Math.max(0, config.maxDataGuess - getDown());
7253 7213
      }
7254 7214

  
7255 7215
      /**
......
7300 7260
            int scrollSize = getAvailableTravelSize() - getThumbSize();
7301 7261
            int maxVal = getMax();
7302 7262
            int position = Coordinate.toInt(Coordinate.scale(
7303
                              (double)dragPos * (double)maxVal / (double)scrollSize));
7263
                              (double)dragPos * (double)maxVal / scrollSize));
7304 7264
            position = Math.max(0, position);
7305 7265
            position = Math.min(position, maxVal);
7306 7266

  
......
7336 7296
            {
7337 7297
               lastExistingRow += 1; // 1-based row number
7338 7298
               dHeight = (double) availSize *
7339
                     (double) lastExistingRow / (double) (lastExistingRow + 1);
7299
                     (double) lastExistingRow / (lastExistingRow + 1);
7340 7300
            }
7341 7301
         }
7342 7302
         else
7343 7303
         {
7344
            dHeight = (double) availSize * (double) getDown() / (double) config.maxDataGuess;
7304
            dHeight = (double) availSize * (double) getDown() / config.maxDataGuess;
7345 7305
         }
7346 7306
         int tHeight = Coordinate.toInt(Coordinate.scale(dHeight));
7347 7307

  
......
7376 7336
         {
7377 7337
            pos = Coordinate.toInt(Coordinate.scale(
7378 7338
                  (double) availSize * (double) getPosition() /
7379
                        (double) (config.maxDataGuess - getDown())));
7339
                        (config.maxDataGuess - getDown())));
7380 7340
            pos = Math.min(pos, availSize);
7381 7341
         }
7382 7342

  
src/com/goldencode/p2j/ui/client/gui/ButtonListGuiImpl.java 2022-03-08 22:06:23 +0000
2 2
** Module   : ButtonListGuiImpl.java
3 3
** Abstract : ButtonListGuiImpl implements the button list widget.
4 4
**
5
** Copyright (c) 2020-2021, Golden Code Development Corporation.
5
** Copyright (c) 2020-2022, Golden Code Development Corporation.
6 6
**
7 7
** -#- -I- --Date-- --------------------------------Description-----------------------------------
8 8
** 001 SBI 20200305 Created initial version.
......
18 18
**     SBI 20210617 Changed to display its first button with expanded items list and fixed its accordion-like style.
19 19
**     RFB 20210726 Protect afterConfigUpdate from indexing into the GroupButtons when it is invalid. 
20 20
**                  Ref #5562.
21
**     VVT 20220306 processKeyEvent: piece of code doing nothing removed.
22
**                  findMouseSource(NativePoint) fixed.
23
**                  findMouseSource(eventId, NativePoint) was overriden. See #6013.
24
**                  setSelected: missing Javadocs added.
21 25
*/
22 26

  
23 27
/*
......
841 845
            return;
842 846
         }
843 847
         
844
         
845
         if (key == Keyboard.KA_CURSOR_LEFT)
846
         {
847
         }
848
         else if (key == Keyboard.KA_CURSOR_RIGHT)
849
         {
850
         }
851
         else if (key == Keyboard.KA_CURSOR_UP || key == Keyboard.KA_CURSOR_DOWN)
852
         {
853
         }
854
         else if (key == Keyboard.KA_RETURN)
855
         {
856
         }
857
         
858 848
         repaint();
859 849
      }
860 850
   }
......
1380 1370
      private Viewport<GuiOutputManager> itemsView;
1381 1371
      
1382 1372
      /** The scroll up button */
1383
      private ButtonGuiImpl scrollUpButton;
1373
      private final ButtonGuiImpl scrollUpButton;
1384 1374
      
1385 1375
      /** The scroll down button */
1386
      private ButtonGuiImpl scrollDownButton;
1376
      private final ButtonGuiImpl scrollDownButton;
1387 1377
      
1388 1378
      /** 
1389 1379
       * Creates the items control for the given items list.
......
1474 1464
      /**
1475 1465
       * Prepares its components.
1476 1466
       */
1467
      @Override
1477 1468
      public void doLayout()
1478 1469
      {
1479 1470
         changeControlState();
......
1581 1572
       * 
1582 1573
       * @return   The item under the mouse pointer.
1583 1574
       */
1575
      @Override
1584 1576
      public Widget<GuiOutputManager> findMouseSource(NativePoint p)
1585 1577
      {
1586 1578
         Widget<GuiOutputManager> w = super.findMouseSource(p);
1587
         
1588
         if (w == scrollDownButton || w == scrollUpButton || w instanceof Item)
1589
         {
1590
            return w;
1591
         }
1592
         
1593
         if (w == null)
1594
         {
1595
            //adjust x-coordinate
1596
            NativeRectangle nd = this.itemsView.physicalBounds();
1597
            
1598
            int x = p.x;
1599
            
1600
            int y = p.y;
1601
            
1602
            if (nd.left() > x)
1603
            {
1604
               x = nd.left() + 1;
1605
            }
1606
            
1607
            if (nd.right() < x)
1608
            {
1609
               x = nd.right() - 1;
1610
            }
1611
            
1612
            w = super.findMouseSource(new NativePoint(x, y));
1613
            
1614
            if (w == scrollDownButton || w == scrollUpButton || w instanceof Item)
1615
            {
1616
               return w;
1617
            }
1618
         }
1619
         
1620
         return w;
1579
         if (w != null)
1580
         {
1581
            return w;
1582
         }
1583

  
1584
         //adjust x-coordinate
1585
         NativeRectangle nd = this.itemsView.physicalBounds();
1586

  
1587
         int x = p.x;
1588

  
1589
         int y = p.y;
1590

  
1591
         if (nd.left() > x)
1592
         {
1593
            x = nd.left() + 1;
1594
         }
1595

  
1596
         if (nd.right() < x)
1597
         {
1598
            x = nd.right() - 1;
1599
         }
1600

  
1601
         return super.findMouseSource(new NativePoint(x, y));
1602
      }
1603

  
1604
      /**
1605
       * Find the source for mouse event.
1606
       * 
1607
       * @param eventId
1608
       *        the event ID to match 
1609
       * @param p
1610
       *        the mouse position relative to this widget
1611
       *        
1612
       * @return the mouse event source or {@code null} if no source found.
1613
       */
1614
      @Override
1615
      public Widget<GuiOutputManager> findMouseSource(int eventId, NativePoint p)
1616
      {
1617
         Widget<GuiOutputManager> w = super.findMouseSource(eventId, p);
1618
         if (w != null)
1619
         {
1620
            return w;
1621
         }
1622

  
1623
         //adjust x-coordinate
1624
         NativeRectangle nd = this.itemsView.physicalBounds();
1625

  
1626
         int x = p.x;
1627

  
1628
         int y = p.y;
1629

  
1630
         if (nd.left() > x)
1631
         {
1632
            x = nd.left() + 1;
1633
         }
1634

  
1635
         if (nd.right() < x)
1636
         {
1637
            x = nd.right() - 1;
1638
         }
1639

  
1640
         return super.findMouseSource(eventId, new NativePoint(x, y));
1621 1641
      }
1622 1642
   }
1623
   
1643

  
1624 1644
   /**
1625 1645
    * Represents a scrollable items list.
1626 1646
    */
......
2042 2062
       * 
2043 2063
       * @return   The item under the mouse pointer.
2044 2064
       */
2065
      @Override
2045 2066
      public Widget<GuiOutputManager> findMouseSource(NativePoint p)
2046 2067
      {
2047 2068
         NativePoint shift = new NativePoint(0, itemIndexOffset * itemHeightInPixels);
......
2073 2094
         
2074 2095
         return super.findMouseSource(p);
2075 2096
      }
2097

  
2098
      /**
2099
       * Find the source for mouse event.
2100
       * 
2101
       * @param eventId
2102
       *        the event ID to match 
2103
       * @param p
2104
       *        the mouse position relative to this widget
2105
       *        
2106
       * @return the mouse event source or {@code null} if no source found.
2107
       */
2108
      @Override
2109
      public Widget<GuiOutputManager> findMouseSource(int eventId, NativePoint p)
2110
      {
2111
         NativePoint shift = new NativePoint(0, itemIndexOffset * itemHeightInPixels);
2112
         
2113
         NativePoint loc = p.minus(shift);
2114
         
2115
         NativeDimension size = getVisibleDimension();
2116
         
2117
         if (loc.x >= 0 && loc.x < size.width && loc.y >= 0 && loc.y <= size.height)
2118
         {
2119
            for (int i = 0, h = 0; i < numberOfVisibleItems; i++, h += itemHeightInPixels)
2120
            {
2121
               if (h <= loc.y && loc.y <= (h + itemHeightInPixels))
2122
               {
2123
                  return get(itemIndexOffset + i);
2124
               }
2125
            }
2126
            
2127
            int limitIndex = itemIndexOffset + numberOfVisibleItems;
2128
            
2129
            // calculate the index of a partly visible or the last item
2130
            if (limitIndex == numberOfAllItems)
2131
            {
2132
               limitIndex--;
2133
            }
2134
            
2135
            return get(limitIndex);
2136
         }
2137
         
2138
         return super.findMouseSource(eventId, p);
2139
      }
2076 2140
   }
2077 2141
   
2078 2142
   /**
......
2135 2199
       * 
2136 2200
       * @return   The item's dimension
2137 2201
       */
2202
      @Override
2138 2203
      public Dimension dimension()
2139 2204
      {
2140 2205
         return new Dimension(this.config.widthChars, this.config.heightChars);
......
2145 2210
       * 
2146 2211
       * @return   The item's width
2147 2212
       */
2213
      @Override
2148 2214
      public double width()
2149 2215
      {
2150 2216
         return dimension().width;
......
2155 2221
       * 
2156 2222
       * @return   The item's height
2157 2223
       */
2224
      @Override
2158 2225
      public double height()
2159 2226
      {
2160 2227
         return dimension().height;
......
2205 2272
         doLayout();
2206 2273
      }
2207 2274
      
2275
      /**
2276
       * Select or deselect this item.
2277
       * 
2278
       * @param isSelected
2279
       *        new selection status
2280
       */
2208 2281
      public void setSelected(boolean isSelected)
2209 2282
      {
2210 2283
         config.selected = isSelected;
......
2271 2344
                * @param    e
2272 2345
                *           The mouse event.
2273 2346
                */
2347
               @Override
2274 2348
               public void mouseClicked(MouseEvent e)
2275 2349
               {
2276 2350
                  ButtonListGuiImpl.this.mouseClicked(e);
......
2500 2574
       * 
2501 2575
       * @return   The item under the mouse pointer.
2502 2576
       */
2577
      @Override
2503 2578
      public Widget<GuiOutputManager> findMouseSource(NativePoint p)
2504 2579
      {
2505 2580
         return this;
2506 2581
      }
2582

  
2583
      /**
2584
       * Find the source for mouse event.
2585
       * 
2586
       * @param eventId
2587
       *        the event ID to match 
2588
       * @param p
2589
       *        the mouse position relative to this widget
2590
       *        
2591
       * @return the mouse event source or {@code null} if no source found.
2592
       */
2593
      @Override
2594
      public Widget<GuiOutputManager> findMouseSource(int eventId, NativePoint p)
2595
      {
2596
         return this;
2597
      }
2507 2598
   }
2508 2599
}
src/com/goldencode/p2j/ui/client/gui/CaptionButton.java 2022-03-06 21:49:25 +0000
2 2
** Module   : CaptionButton.java
3 3
** Abstract : Define caption button associated with a window.
4 4
**
5
** Copyright (c) 2014-2017, Golden Code Development Corporation.
5
** Copyright (c) 2014-2022, Golden Code Development Corporation.
6 6
**
7 7
** -#- -I- --Date-- ---------------------------------Description----------------------------------
8 8
** 001 CA  20140805 Created initial version.
......
33 33
** 019 OM  20170407 Fixed list of handled mouseActions.
34 34
** 020 HC  20170823 Removed unused code of the window-state runtime logic.
35 35
** 021 SBI 20190908 Changed to send the window close command directly to the OS queue.
36
** 022 VVT 20220306 mouseActions: MouseEvent.MOUSE_MOVED was added to the list of actions. See #6013.
36 37
*/
37 38
/*
38 39
** This program is free software: you can redistribute it and/or modify
......
308 309
         MouseEvent.MOUSE_ENTERED,
309 310
         MouseEvent.MOUSE_EXITED,
310 311
         MouseEvent.MOUSE_DRAGGED,
312
         MouseEvent.MOUSE_MOVED
311 313
      };
312 314

  
313 315
      return res;
src/com/goldencode/p2j/ui/client/gui/EditorGuiImpl.java 2022-03-06 21:49:25 +0000
2 2
** Module   : EditorGuiImpl.java
3 3
** Abstract : EDITOR widget implementation. GUI-specific version.
4 4
**
5
** Copyright (c) 2015-2021, Golden Code Development Corporation.
5
** Copyright (c) 2015-2022, Golden Code Development Corporation.
6 6
**
7 7
** -#- -I- --Date-- ----------------------------------------Description---------------------------------------
8 8
** 001 CA  20150509 Created initial version.
......
100 100
**     CA  20211206 isPrintableKey() must know if the key is real or not, as its code can be used only when 
101 101
**                  the key is originating from a real key press; otherwise, its label must be checked, as the 
102 102
**                  key code may be for a legacy event name, which can collide with a real UTF-8 key code.
103
**     VVT 20220306 findMouseSource(eventId, NativePoint) was overriden. See #6013.
103 104
*/
104 105

  
105 106
/*
......
1811 1812
   }
1812 1813

  
1813 1814
   /**
1815
    * Find the source for mouse event.
1816
    * 
1817
    * @param eventId
1818
    *        the event ID to match 
1819
    * @param p
1820
    *        the mouse position relative to this widget
1821
    *        
1822
    * @return the mouse event source or {@code null} if no source found.
1823
    */
1824
   @Override
1825
   public Widget<GuiOutputManager> findMouseSource(int eventId, NativePoint p)
1826
   {
1827
      Widget<GuiOutputManager> src = super.findMouseSource(eventId, p);
1828
      
1829
      return (src == editor || src == contentPane) ? this : src;
1830
   }
1831

  
1832
   /**
1814 1833
    * Get the widget's actual bounds
1815 1834
    * 
1816 1835
    * @return widget's actual bounds
src/com/goldencode/p2j/ui/client/gui/FrameGuiImpl.java 2022-03-06 21:49:25 +0000
2 2
** Module   : FrameGuiImpl.java
3 3
** Abstract : Frame implementation for GUI
4 4
**
5
** Copyright (c) 2014-2021, Golden Code Development Corporation.
5
** Copyright (c) 2014-2022, Golden Code Development Corporation.
6 6
**
7 7
** -#- -I- --Date-- ---------------------------------Description---------------------------------
8 8
** 001 MAG 20141010 Created initial version.
......
157 157
**     EVL 20220112 Fix for missed mouse drag event in web client.
158 158
**     AL2 20220127 Register all realized frames as empty selectors: can deselect all widgets from a window.
159 159
**     VVT 20220218 Javadocs and other cosmetic fixes.
160
**     VVT 20220306 findMouseSource(eventId, NativePoint) was overriden. See #6013.
160 161
*/
161 162

  
162 163
/*
......
1107 1108
      return foundWidget;
1108 1109
   }
1109 1110

  
1111
   @Override
1112
   public Widget<GuiOutputManager> findMouseSource(int eventId, NativePoint p)
1113
   {
1114
      // the point incoming is related to frame origin, we need to substract the frame title
1115
      NativePoint pCheck = hasTitle() ? p.minus(frameScroll.physicalLocation()) : p;
1116
      
1117
      Widget<GuiOutputManager> foundWidget = frameScroll.findMouseSource(eventId, pCheck);
1118
      
1119
      if (foundWidget == null)
1120
      {
1121
         foundWidget = (this.physicalBounds().contains(p) ? this : null);
1122
      }
1123
      
1124
      // if the widget is a label, the "source" will be the frame scroll in order to prevent
1125
      // exit and enter mouse events for the frame if the mouse pointer is over the label.
1126
      if (foundWidget instanceof LabelGuiImpl)
1127
      {
1128
         return frameScroll;
1129
      }
1130
      
1131
      // if the widget is not enabled, then the source is the frame, too
1132
      if (foundWidget != null                              &&
1133
          foundWidget.config() != null                     &&
1134
          !WidgetId.virtualWidget(foundWidget.config().id) &&
1135
          !foundWidget.isEnabled()) // TODO: tooltips work with disabled widgets
1136
      {
1137
         return this;
1138
      }
1139
      
1140
      return foundWidget;
1141
   }
1110 1142
   /**
1111 1143
    * Get a point to represent the LAST-EVENT:X and LAST-EVENT:Y coordinates.  For frames, these
1112 1144
    * represents a point relative to the frame's top-left corner (excluding title).
src/com/goldencode/p2j/ui/client/gui/ModalWindow.java 2022-03-09 17:35:49 +0000
74 74
**                  method added. See #6013.
75 75
**     VVT 20220215 Change 13474 for #6013 temporary reverted (caused multiple regressions,
76 76
**                  need to be completed).
77
**     VVT 20220306 findMouseSource(eventId, NativePoint) was overriden. See #6013.
77 78
*/
78 79
/*
79 80
** This program is free software: you can redistribute it and/or modify
......
165 166
   /** Cached GUI driver reference. */  
166 167
   protected GuiDriver<?,?> gd;
167 168

  
168
   /** The last mouse pressed determined for this window. */
169
   private Widget<GuiOutputManager> mousePressedSource = null;
170
   
171 169
   /** Destroy flag. */
172 170
   protected boolean destroyInProgress;
173 171
   
......
640 638
   }
641 639
   
642 640
   /**
643
    * Get the title bar widget associated witn this window.
641
    * Get the title bar widget associated with this window.
644 642
    * 
645 643
    * @return   See above.
646 644
    */
......
747 745
   }
748 746
   
749 747
   /**
750
    * Find the widget to which the given mouse event can be applied.
751
    * 
752
    * @param    evt
753
    *           The mouse event.
754
    * 
755
    * @return   A widget over which the mouse is positioned or {@code null} if none found.
756
    */
757
   @Override
758
   public Widget<GuiOutputManager> findMouseSource(MouseEvt evt)
759
   {
760
      Widget<GuiOutputManager> widget = null;
761
      
762
      int evtID = evt.getEvent().getID();
763
      
764
      if (evtID == MouseEvent.MOUSE_DRAGGED  || 
765
          evtID == MouseEvent.MOUSE_RELEASED ||
766
          evtID == MouseEvent.MOUSE_CLICKED)
767
      {
768
         return mousePressedSource;
769
      }
770
      
771
      try
772
      {
773
         java.awt.Point p = evt.getEvent().getPoint();
774
         
775
         // search the other widgets
776
         widget = windowPane.findMouseSource(new NativePoint(p.x, p.y));
777
         
778
         widget = (widget == null ? this : widget);
779
      }
780
      finally
781
      {
782
         if (widget != null && evtID == MouseEvent.MOUSE_PRESSED)
783
         {
784
            mousePressedSource = widget;
785
         }
786
         
787
         if (evtID == MouseEvent.MOUSE_CLICKED)
788
         {
789
            mousePressedSource = null;
790
         }
791
      }
792
      
793
      return widget;
748
    * Find the source for mouse event.
749
    * 
750
    * @param eventId
751
    *        the event ID to match 
752
    * @param p
753
    *        the mouse position relative to this widget
754
    *        
755
    * @return the mouse event source or {@code null} if no source found.
756
    */
757
   @Override
758
   public Widget<GuiOutputManager> findMouseSource(int eventId, NativePoint p)
759
   {
760
      return windowPane.findMouseSource(eventId, p);
761
   }
762

  
763
   /**
764
    * Find the widget positioned just bellow the specified mouse position (in physical units).
765
    * Each container should search for own widgets. Because widgets are relative positioned 
766
    * inside containers the container physical position is adjusted before search.  
767
    * 
768
    * @param    p
769
    *           The mouse physical location.
770
    * 
771
    * @return   A widget over which the mouse is positioned or <code>null</code> if none found.
772
    */
773
   @Override
774
   public Widget<GuiOutputManager> findMouseSource(NativePoint p)
775
   {
776
      return windowPane.findMouseSource(p);
794 777
   }
795 778

  
796 779
   /**
src/com/goldencode/p2j/ui/client/gui/OverlayWindow.java 2022-03-09 22:24:45 +0000
542 542
   }
543 543
   
544 544
   /**
545
    * Find the widget to which the given mouse event can be applied.
546
    * 
547
    * @param    evt
548
    *           The mouse event.
549
    * 
550
    * @return   A widget over which the mouse is positioned or {@code null} if none found.
551
    */
552
   @Override
553
   public Widget<GuiOutputManager> findMouseSource(MouseEvt evt)
554
   {
555
      Widget<GuiOutputManager> widget = null;
556
      
557
      int evtID = evt.getEvent().getID();
558
      
559
      if (evtID == MouseEvent.MOUSE_DRAGGED  || 
560
          evtID == MouseEvent.MOUSE_RELEASED ||
561
          evtID == MouseEvent.MOUSE_CLICKED)
562
      {
563
         return mousePressedSource;
564
      }
565
      
566
      try
567
      {
568
         java.awt.Point p = evt.getEvent().getPoint();
569
         
570
         // search the other widgets
571
         widget = findMouseSource(new NativePoint(p.x, p.y));
572
         
573
         widget = (widget == null ? this : widget);
574
      }
575
      finally
576
      {
577
         if (widget != null && evtID == MouseEvent.MOUSE_PRESSED)
578
         {
579
            mousePressedSource = widget;
580
         }
581
      }
582
      
583
      return widget;
584
   }
585

  
586
   /**
587 545
    * Get a point to represent the LAST-EVENT:X and LAST-EVENT:Y coordinates.  For overlay windows,
588 546
    * these returns always <code>null</code>.
589 547
    * 
... This diff was truncated because it exceeds the maximum size that can be displayed.