|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.ui.SoftKeyBar
A SoftKeyBar is used on Smartphone or other such systems where general purpose hardware keys are used to control inputs to the software in a way that changes depending on the situation.
SoftKeyBars provide two types of controls - buttons which simply fire an action when the associated softkey is pressed, or menus which display a general Menu when pressed.
The SoftKeyBar is not a UI Control since it may actually be implemented using the system's native UI system - but it is fully responsible for configuring the appearance on screen and handling the softkey presses. The only thing an application has to do is to trap the events sent out by the SoftKeyBar or override the event handling of the SoftKeyBar.
Because only one SoftKeyBar can be displayed at a time, you display it by calling Window.setSoftKeyBar() on the containing Window.
| Field Summary | |
int |
barModifiersToClear
|
int |
barModifiersToSet
|
static Color |
defaultBackgroundColor
The default background color for the soft keys. |
static Font |
defaultFont
This is the default font. |
static SoftKeyBar |
empty
|
static boolean |
hideRemovesSoftKeyBar
This is false by default and if you set it true, then a hide() will cause the SoftKeyBar to disappear entirely, instead of just becoming empty - which is the default. |
String |
name
You can use this as an identifier for bar. |
| Constructor Summary | |
SoftKeyBar()
|
|
SoftKeyBar(EventListener listener)
|
|
| Method Summary | |
void |
addListener(EventListener el)
|
void |
addTo(SingleContainer sc)
|
void |
clearKeys()
|
Menu |
createMenuFor(Object obj)
Create a Menu for a specific set of Objects, placed in a Vector, or a Container or an Object array. |
MenuItem |
createMenuItem(mButton button)
Return a MenuItem that will be used as a proxy for a specific buton. |
MenuItem |
createMenuItem(String label,
String action,
IImage icon)
|
MenuItem |
createMenuItem(String label,
String action,
String iconName,
Object maskOrColor)
|
MenuItem |
createMenuItemFor(Object obj)
Create a MenuItem for a particular Object. |
boolean |
display()
Display the SoftKeyBar in the global SoftKeyBar location. |
static Menu |
fixMenu(Menu m)
Fix a Menu for use with the SoftKeyBar. |
static SoftKeyBar |
getDisplayed()
|
FontMetrics |
getFontMetrics()
|
boolean |
handleKey(KeyEvent ev)
|
static void |
hide()
Hide any visible SoftKeyBar. |
protected Control |
make()
|
static int |
numberOfKeys()
Returns the number of keys supported by the system. |
void |
onEvent(Event ev)
|
static boolean |
onKeyEvent(KeyEvent ev)
|
static void |
pop()
Display the keybar that was displayed before the last push() call. |
static void |
push(SoftKeyBar skb)
Display a new keybar, but save the old keybar. |
void |
removeListener(EventListener el)
|
static boolean |
reveal()
Reveal a hidden SoftKeyBar. |
protected void |
sendToListeners(Event ev)
|
void |
setFont(Font f)
Set the Font to be used by the bar if possible. |
SoftKeyBar |
setKey(int which,
IImage image,
Menu menu)
|
SoftKeyBar |
setKey(int which,
mButton button)
Set one of the SoftKeyBar keys to be a proxy for an existing mButton. |
SoftKeyBar |
setKey(int which,
Object obj,
String label)
Set one of the SoftKeys to be a button or a Menu, depending on the type of the obj parameter. |
SoftKeyBar |
setKey(int which,
String text,
IImage icon,
Menu menu)
|
SoftKeyBar |
setKey(int which,
String text,
Menu menu)
|
SoftKeyBar |
setKey(int which,
String text,
String iconName,
Object maskOrColor,
Menu menu)
|
SoftKeyBar |
setMenu(int which,
String name,
IImage icon,
String items)
Set a particular softkey to be a Menu, specifying the menu as a String. |
SoftKeyBar |
setMenu(int which,
String name,
String iconName,
Object maskOrColor,
String items)
Set a particular softkey to be a Menu, specifying the menu as a String. |
static void |
setupIn(Panel c)
Setup the global location for the SoftKeyBar. |
static void |
setupScreen()
This is called by the GUI system when running on a Smartphone. |
static boolean |
supportsImages()
Returns true if the softkey displays on screen supports the display of images, false if not. |
static boolean |
usingSoftKeys()
This returns true if SoftKeys are under this platform. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Field Detail |
public String name
public static Color defaultBackgroundColor
public static boolean hideRemovesSoftKeyBar
public int barModifiersToSet
public int barModifiersToClear
public static final SoftKeyBar empty
public static Font defaultFont
| Constructor Detail |
public SoftKeyBar()
public SoftKeyBar(EventListener listener)
| Method Detail |
public void addListener(EventListener el)
public void removeListener(EventListener el)
protected void sendToListeners(Event ev)
public void clearKeys()
public void setFont(Font f)
f - the Font to use if this is allowed by the system. If setting of the Font is not allowed,
then this method will have no effect.public static boolean supportsImages()
public static int numberOfKeys()
public void onEvent(Event ev)
onEvent in interface EventListenerpublic FontMetrics getFontMetrics()
public MenuItem createMenuItem(String label,
String action,
String iconName,
Object maskOrColor)
public MenuItem createMenuItem(String label,
String action,
IImage icon)
public MenuItem createMenuItem(mButton button)
public SoftKeyBar setKey(int which,
mButton button)
which - the key to set, either 1 (left) or 2 (right.button - the button that will be activated by the Soft Key.
public MenuItem createMenuItemFor(Object obj)
throws IllegalArgumentException
obj - - this can be a String or an mButton, each of which creates a normal MenuItem,
or it can be a Menu or Vector or Object[] or a Container, in which case a MenuItem that has
a sub-menu will be created.
IllegalArgumentException
public Menu createMenuFor(Object obj)
throws IllegalArgumentException
IllegalArgumentException
public SoftKeyBar setKey(int which,
Object obj,
String label)
throws IllegalArgumentException
which - the key to set, either 1 (left) or 2 (right.obj - this can be either a String or mButton (either of which creates a single
button for the Soft Key) or a Vector or Object[] or Container or Menu - in which
case a Menu will be created for the Soft Key.label - if the obj parameter gets converted to a Menu, then this parameter will
be the label for the menu.
IllegalArgumentException
public SoftKeyBar setKey(int which,
IImage image,
Menu menu)
throws IllegalArgumentException
which - The key to set, starting from 1.image - The image to use for the key.menu - An optional menu to display when the key is pressed. If this is null the key
will just be treated as a button.
IllegalArgumentException - if the system does not support displaying images on the
soft keys.
public SoftKeyBar setKey(int which,
String text,
IImage icon,
Menu menu)
throws IllegalArgumentException
which - The key to set, starting from 1.text - The text for the key. If this is in the form "Text_1|Text_2" then "Text_1" is used
as the text for the key and "Text_2" is used as the action for the key.icon - An image to display as an icon next to the text if possible. If this is not possible
then the icon is ignored.menu - An optional menu to display when the key is pressed. If this is null the key
will just be treated as a button.
IllegalArgumentException - if the system does not support displaying images on the
soft keys.
public SoftKeyBar setKey(int which,
String text,
Menu menu)
which - The key to set, starting from 1.text - The text for the key. If this is in the form "Text_1|Text_2" then "Text_1" is used
as the text for the key and "Text_2" is used as the action for the key.menu - An optional menu to display when the key is pressed. If this is null the key
will just be treated as a button with the Text and action for the button being the same.
IllegalArgumentException - if the system does not support displaying images on the
soft keys.
public SoftKeyBar setKey(int which,
String text,
String iconName,
Object maskOrColor,
Menu menu)
which - The key to set, starting from 1.text - The text for the key. If this is in the form "Text_1|Text_2" then "Text_1" is used
as the text for the key and "Text_2" is used as the action for the key.iconName - The name of the saved image.maskOrColor - A name of a mask image or a color mask for the icon, or null.menu - An optional menu to display when the key is pressed. If this is null the key
will just be treated as a button.
IllegalArgumentException - if the system does not support displaying images on the
soft keys.
public SoftKeyBar setMenu(int which,
String name,
IImage icon,
String items)
which - The key to set, starting from 1.name - The name of the menu.icon - An optional icon for the menu.items - The items for the menu. This should be specified either as a
comma separted list of item names (e.g. "Item 1,Item 2,Item 3") or as a '|' separated list of
item name and action pairs (e.g. "Item 1|ACTION_1|Item 2|ACTION_2|Item 3|ACTION_3").
public SoftKeyBar setMenu(int which,
String name,
String iconName,
Object maskOrColor,
String items)
which - The key to set, starting from 1.name - The name of the menu.iconName - The name of the saved image.maskOrColor - A name of a mask image or a color mask for the icon, or null.items - The items for the menu. This should be specified either as a
comma separted list of item names (e.g. "Item 1,Item 2,Item 3") or as a '|' separated list of
item name and action pairs (e.g. "Item 1|ACTION_1|Item 2|ACTION_2|Item 3|ACTION_3").protected Control make()
public boolean handleKey(KeyEvent ev)
public static boolean onKeyEvent(KeyEvent ev)
public void addTo(SingleContainer sc)
public static boolean usingSoftKeys()
public static void setupIn(Panel c)
public boolean display()
public static SoftKeyBar getDisplayed()
public static void setupScreen()
public static void hide()
public static boolean reveal()
public static void push(SoftKeyBar skb)
public static void pop()
public static Menu fixMenu(Menu m)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||