Revision: 2746
http://sourceforge.net/p/swingme/code/2746
Author: yuranet
Date: 2023-06-07 20:14:56 +0000 (Wed, 07 Jun 2023)
Log Message:
-----------
fix for text field popup menu not working
Modified Paths:
--------------
SwingME/src/net/yura/mobile/gui/DesktopPane.java
SwingME/src/net/yura/mobile/gui/components/Button.java
SwingME/src/net/yura/mobile/gui/components/Component.java
SwingME/src/net/yura/mobile/gui/components/List.java
SwingME/src/net/yura/mobile/gui/components/Menu.java
SwingME/src/net/yura/mobile/gui/components/ScrollPane.java
SwingME/src/net/yura/mobile/gui/components/Spinner.java
SwingME/src/net/yura/mobile/gui/components/TextComponent.java
SwingME/src/net/yura/mobile/gui/components/TextField.java
Modified: SwingME/src/net/yura/mobile/gui/DesktopPane.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/DesktopPane.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/DesktopPane.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -110,7 +110,7 @@
}
com.updateUI();
- Window popup = com.getPopupMenu();
+ Window popup = com.getComponentPopupMenu();
if ( popup!=null ) {
updateComponentTreeUI(popup);
}
@@ -1451,15 +1451,23 @@
pointerScrollPane = null;
}
// check its dragged more then 5px
- else if (!(isAccurate(pointerFirstX, x, inaccuracy) && isAccurate(pointerFirstY, y, inaccuracy))) {
- // we do NOT yet have the x and y for this event inside the component (calculated further down)
- // we send 0,0 as there is nothing the component should be doing with the location anyway
- pointerComponent.processMouseEvent(CANCEL, 0, 0, keypad);
- pointerComponent = null;
+ else if (!isAccurate(pointerFirstX, x, inaccuracy) || !isAccurate(pointerFirstY, y, inaccuracy)) {
- if (DEFAULT_NO_FOCUS) {
- currentWindow.setNothingFocused();
+ // check if we can actually scroll this scrollpane
+ Component scrollView = pointerScrollPane.getView();
+ if (scrollView != null && (scrollView.getHeight() > pointerScrollPane.getViewPortHeight() || scrollView.getWidth() > pointerScrollPane.getViewPortWidth())) {
+ // we do NOT yet have the x and y for this event inside the component (calculated further down)
+ // we send 0,0 as there is nothing the component should be doing with the location anyway
+ pointerComponent.processMouseEvent(CANCEL, 0, 0, keypad);
+ pointerComponent = null;
+
+ if (DEFAULT_NO_FOCUS) {
+ currentWindow.setNothingFocused();
+ }
}
+ else {
+ pointerScrollPane = null;
+ }
}
}
Modified: SwingME/src/net/yura/mobile/gui/components/Button.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Button.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/Button.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -262,7 +262,7 @@
selected = true;
repaint();
}
- else if (type == DesktopPane.CANCEL || isPopupTrigger(type, keys)) { // user scrolls or popup menu open
+ else if (type == DesktopPane.CANCEL || getPopupIfTriggered(type, keys) != null) { // user scrolls or popup menu open
selected = oldState;
repaint();
}
Modified: SwingME/src/net/yura/mobile/gui/components/Component.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Component.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/Component.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -496,15 +496,13 @@
*/
public void processMouseEvent(int type, int x, int y, KeyEvent buttons) {
- if (isPopupTrigger(type, buttons)) {
- Window popup = getPopupMenu();
- if (popup != null && !popup.isVisible()) {
- // no action listener is called, if you want to customise menu, override getPopupMenu()
- popup.show(this, x + getXOnScreen(), y + getYOnScreen());
+ Window popup = getPopupIfTriggered(type, buttons);
+ if (popup != null && !popup.isVisible()) {
+ // no action listener is called, if you want to customise menu, override getPopupMenu()
+ popup.show(this, x + getXOnScreen(), y + getYOnScreen());
- // if we opened a popup menu, we do not want to open any parent popup menu
- return;
- }
+ // if we opened a popup menu, we do not want to open any parent popup menu
+ return;
}
if (focusable) {
@@ -523,10 +521,11 @@
}
/**
+ * Checks if the event should trigger a popup menu and if yes then returns the popup menu
* @see java.awt.event.MouseEvent#isPopupTrigger()
*/
- protected boolean isPopupTrigger(int type, KeyEvent buttons) {
- return type == DesktopPane.RELEASED && buttons.isDownKey(KeyEvent.KEY_RIGHT_CLICK) && popup != null;
+ protected Window getPopupIfTriggered(int mouseEventType, KeyEvent buttons) {
+ return mouseEventType == DesktopPane.RELEASED && buttons.isDownKey(KeyEvent.KEY_RIGHT_CLICK) ? getComponentPopupMenu() : null;
}
public void processMultitouchEvent(int[] type, int[] x, int[] y) {
@@ -939,7 +938,7 @@
* @see javax.swing.JMenu#getPopupMenu() JMenu.getPopupMenu
* @see javax.swing.JComponent#getComponentPopupMenu()
*/
- public Window getPopupMenu() {
+ public Window getComponentPopupMenu() {
return popup;
}
}
Modified: SwingME/src/net/yura/mobile/gui/components/List.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/List.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/List.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -561,7 +561,7 @@
setSelectedIndex(-1);
}
}
- else if (type == DesktopPane.RELEASED && !isPopupTrigger(type, keys) && !isCtrlKeyDown(keys)) {
+ else if (type == DesktopPane.RELEASED && getPopupIfTriggered(type, keys) == null && !isCtrlKeyDown(keys)) {
if (doubleClick) {
long time = System.currentTimeMillis();
Modified: SwingME/src/net/yura/mobile/gui/components/Menu.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Menu.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/Menu.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -74,9 +74,9 @@
*/
// Override
- protected boolean isPopupTrigger(int type, KeyEvent buttons) {
+ protected Window getPopupIfTriggered(int mouseEventType, KeyEvent buttons) {
// do not trigger popup menus, just open menu as normal
- return false;
+ return null;
}
public void fireActionPerformed() {
Modified: SwingME/src/net/yura/mobile/gui/components/ScrollPane.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/ScrollPane.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/ScrollPane.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -417,7 +417,6 @@
}
}
}
-
}
public void paintChildren(Graphics2D g) {
Modified: SwingME/src/net/yura/mobile/gui/components/Spinner.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/Spinner.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/Spinner.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -143,7 +143,7 @@
fire();
}
// if we started scrolling or opened a popup menu
- else if (type == DesktopPane.CANCEL || isPopupTrigger(type, keys)) {
+ else if (type == DesktopPane.CANCEL || getPopupIfTriggered(type, keys) != null) {
Object newVal=null;
if (leftPress) {
leftPress = false;
Modified: SwingME/src/net/yura/mobile/gui/components/TextComponent.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/TextComponent.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/TextComponent.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -920,7 +920,7 @@
return x;
}
- public Window getPopupMenu() {
+ public Window getComponentPopupMenu() {
if (popup!=null) return popup;
if (!isFocusable()) return null;
Modified: SwingME/src/net/yura/mobile/gui/components/TextField.java
===================================================================
--- SwingME/src/net/yura/mobile/gui/components/TextField.java 2023-05-31 17:15:35 UTC (rev 2745)
+++ SwingME/src/net/yura/mobile/gui/components/TextField.java 2023-06-07 20:14:56 UTC (rev 2746)
@@ -19,6 +19,7 @@
import javax.microedition.lcdui.Canvas;
import net.yura.mobile.gui.ActionListener;
+import net.yura.mobile.gui.DesktopPane;
import net.yura.mobile.gui.Graphics2D;
import net.yura.mobile.gui.KeyEvent;
import net.yura.mobile.gui.plaf.Style;
@@ -86,8 +87,8 @@
public void processMouseEvent(int type, int x, int y, KeyEvent keys) {
super.processMouseEvent(type, x, y, keys);
- if (focusable) {
- String txt = getDisplayString()+" ";
+ if (focusable && type != DesktopPane.CANCEL) { // if this is a pressed or released event
+ String txt = getDisplayString() + " ";
int mid = searchStringCharOffset(txt,font,x -offset);
setCaretPosition(mid);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|