diff --git a/enough-polish-j2me/source/src/de/enough/polish/ui/Item.java b/enough-polish-j2me/source/src/de/enough/polish/ui/Item.java
index d3a7aa0..a645ec0 100644
--- a/enough-polish-j2me/source/src/de/enough/polish/ui/Item.java
+++ b/enough-polish-j2me/source/src/de/enough/polish/ui/Item.java
@@ -50,6 +50,7 @@
import de.enough.polish.util.ArrayList;
import de.enough.polish.util.Arrays;
import de.enough.polish.util.DeviceControl;
+import de.enough.polish.util.DeviceInfo;
import de.enough.polish.util.DrawUtil;
import de.enough.polish.util.HashMap;
import de.enough.polish.util.RgbImage;
@@ -809,7 +810,11 @@ public abstract class Item implements UiElement, Animatable
//#endif
protected Style focusedStyle;
protected boolean isPressed;
- //#if polish.css.pressed-style
+ //#if (polish.isDynamic && !polish.Item.UseHoverStylesForTouchSystems) || (!polish.isDynamic && polish.hasPointerEvents && !polish.Item.UseHoverStylesForTouchSystems)
+ //#define tmp.dontUseHoverForTouchSystems
+ //#endif
+ //#if polish.css.pressed-style || tmp.dontUseHoverForTouchSystems
+ //#define tmp.pressedStyle
private Style normalStyle;
private Style pressedStyle;
//#endif
@@ -1302,6 +1307,12 @@ public void setStyle( Style style ) {
if (pressed != null) {
this.pressedStyle = pressed;
}
+ //#if tmp.dontUseHoverForTouchSystems
+ if (this.pressedStyle == null && DeviceInfo.hasPointerEvents())
+ {
+ this.pressedStyle = this.focusedStyle;
+ }
+ //#endif
//#endif
//#if polish.css.complete-background
@@ -4454,7 +4465,7 @@ public boolean notifyItemPressedStart() {
System.out.println("notifyItemPressedStart for " + this);
this.isPressed = true;
boolean handled = false;
- //#if polish.css.pressed-style
+ //#if tmp.pressedStyle
//System.out.println("notifyItemPressedStart for " + this + ", pressedStyle=" + (this.pressedStyle != null ? this.pressedStyle.name : "Item
+
<variable name="" value="" />
+colors { focusedFontColor: #111; focusedBorderColor: #444; @@ -54,7 +54,7 @@@@ -83,16 +83,17 @@Designing the Focused Element
layout: expand | left; } -.mailBox:hover { +.mailBox:hover { background-border-color: focusedBorderColor; }Tips and Tricks
The following example shows the above example in which we increase the border width in the focused state. We accordingly adjust the margins, so that there is no wobbling when the user moves to the next item:
-+.mailBox { - margin: 1; - padding: 2; - padding-left: 9; - padding-right: 9; + margin: 1px; + padding: 2px; + padding-left: 9px; + padding-right: 9px; background { type: round-rect; color: mailBoxBgColor; border-color: mailBoxBorderColor; + border-width: 1px; } font { style: bold; @@ -103,8 +104,8 @@@@ -123,6 +124,19 @@Tips and Tricks
} .mailBox:hover { - margin: 0; - background-border-width: 2; + margin: 0px; + background-border-width: 2px; background-border-color: focusedBorderColor; }Programming
You can focus an item and showing the corresponding screen at the same time by callingDisplay.setCurrentItem( Item item )
. +Default Behavior on Touch Handsets
++ If you are targeting touch enabled devices + (or a dynamic device such as Generic/AnyPhone and run the app on a touch enabled device), then J2ME Polish will use the
+:hover
style + when no:pressed
style is defined.
+ If you don't want this behavior and only use:pressed
when it is actually used and + want to apply:hover
styles on touch enabled devices as well, then you set the + preprocessing variablepolish.Item.UseHoverStylesForTouchSystems
totrue
: ++ <variable name="polish.Item.UseHoverStylesForTouchSystems" value="true" /> ++JavaDoc
+menuItem { padding: 2; font-color: black; @@ -28,10 +28,21 @@+Designing the Pressed Element
font-color: white; } -menuItem:pressed { +menuItem:pressed { background-color: #9f9; font-color: #222; -} +} ++If you are targeting touch enabled devices +(or a dynamic device such as Generic/AnyPhone and run the app on a touch enabled device), then J2ME Polish will use the
+:hover
style +when no:pressed
style is defined.
+If you don't want this behavior and only use:pressed
when it is actually used and +want to apply:hover
styles on touch enabled devices as well, then you set the +preprocessing variablepolish.Item.UseHoverStylesForTouchSystems
totrue
: ++<variable name="polish.Item.UseHoverStylesForTouchSystems" value="true" />You are not limited in the design, typically you will use a different background or a different border for the pressed state of an item, but depending on the item you can also exchange icon-images, font-styles, @@ -72,7 +83,7 @@
Designing the Pressed Element
-+.mainCommand { padding: 0; padding-vertical: 0; @@ -88,9 +99,9 @@<%include end.txt %> diff --git a/enough-polish-website/site/source/docs/gui-touchsupport.html b/enough-polish-website/site/source/docs/gui-touchsupport.html index 633f4a6..6349e23 100644 --- a/enough-polish-website/site/source/docs/gui-touchsupport.html +++ b/enough-polish-website/site/source/docs/gui-touchsupport.html @@ -3,7 +3,7 @@ <%define inDocumentationSection.css %> <%set title = J2ME Polish: Documentation: Touch Support %> <%set basedir = ../ %> -<%include start.txt %> +<%include start_syntax.txt %>Designing the Pressed Element
text-effect: shadow; } -.mainCommand:pressed { +.mainCommand:pressed { view-type: particle; -} +}Touch Support
@@ -203,12 +203,19 @@Touch Support and Focus
With this preprocessing variable set to true, the focus remains on the last selected item when a scrollable area is dragged or scrolled. -Virtual keyboard
-- When using TextFields in your Screens you can also use an virtual keyboard to enter text. - This allows you to edit text inline instead of opening up a native editor which might require more clicks or which might confuse the user. Please - have a look at the virtual keyboard documentation. -
+:hover and :pressed on devices
++ If you are targeting touch enabled devices + (or a dynamic device such as Generic/AnyPhone and run the app on a touch enabled device), then J2ME Polish will use the
+:hover
style + when no:pressed
style is defined.
+ If you don't want this behavior and only use:pressed
when it is actually used and + want to apply:hover
styles on touch enabled devices as well, then you set the + preprocessing variablepolish.Item.UseHoverStylesForTouchSystems
totrue
: ++ <variable name="polish.Item.UseHoverStylesForTouchSystems" value="true" /> ++Sample Application