|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.Field
net.rim.device.api.ui.toolbar.ToolbarButtonField
public class ToolbarButtonField
Represents a toolbar button field.
Each item has an ordinal specifying the sort order within the toolbar. The items are sorted left-to-right on the toolbar (with the higher ordinal on the left).
To create toolbar fields in your own application create instances of this class and populate them with aCommand
instance or extend this class. Your subclasses must
implement the ToolbarButtonField.invoke()
method which is called by the ToolbarManager
.
Field Summary |
---|
Constructor Summary | ||
---|---|---|
ToolbarButtonField()
Creates an instance of ToolbarButtonField with an ordinal of 0. |
||
ToolbarButtonField(int ordinal)
Creates an instance of ToolbarButtonField with a specified priority order. |
||
ToolbarButtonField(int ordinal,
long style)
Creates an instance of ToolbarButtonField , which a specified order and style. |
||
ToolbarButtonField(long style)
Creates an instance of ToolbarButtonField with a specified style. |
||
ToolbarButtonField(Image image,
StringProvider text)
Creates an instance of ToolbarButtonField with the specified image and text. |
||
ToolbarButtonField(Image image,
StringProvider text,
int ordinal)
Creates an instance of ToolbarButtonField with the specified image, text, and ordinal. |
||
ToolbarButtonField(Image image,
StringProvider text,
int ordinal,
long style)
Creates an instance of ToolbarButtonField with the specified style, image, text, and ordinal. |
||
ToolbarButtonField(StringProvider text)
Create an instance of ToolbarButtonField with the specified text to use if an
image or tooltip is not provided. |
||
ToolbarButtonField(StringProvider text,
int ordinal)
Creates an instance of ToolbarButtonField with the specified text and ordinal. |
Method Summary | ||
---|---|---|
Command |
getCommand()
Retrieves this ToolbarButtonField instance's associated Command |
|
Image |
getImage()
Image used by this ToolbarButtonField . |
|
int |
getOrdinal()
The ordinal defines the sort order for a ToolbarButtonField. |
|
int |
getPreferredHeight()
Retrieves the preferred height of the ToolbarButtonField (equivalent to the preferred height
of the ToolbarManager ). |
|
int |
getPreferredWidth()
By default this method returns 0. |
|
String |
getText()
Retrieves the text used on a ToolbarButtonField if an image is not available or a tooltip
is not provided. |
|
String |
getTooltip()
Retrieves the text used as a tooltip when the user hovers over a ToolbarButtonField . |
|
void |
invoke()
Performs an action when this ToolbarButtonField is clicked on if Command has been set. |
|
boolean |
isEnabled()
Determines if the ToolbarButtonField is enabled. |
|
protected void |
layout(int width,
int height)
Always consumes the width and height provided. |
|
protected void |
onDisplay()
If this field was previously obscured, invalidates and enables it. |
|
protected void |
onExposed()
If this field was previously obscured, invalidates and enables it. |
|
protected void |
onObscured()
If this field is obscured by another screen which is capable of accepting input or receiving focus, this method disables out the toolbar. |
|
void |
paint(Graphics g)
Paints the ToolbarButtonField . |
|
void |
run()
Calls the ToolbarButtonField.invoke() method if and only if the ToolbarButtonField is enabled. |
|
void |
setCommand(Command command)
Sets the Command to invoke when a ToolbarButtonField is activated. |
|
void |
setCommandContext(Object commandContext)
Sets command context to use when button is activated. |
|
void |
setEnabled(boolean enabled)
Set whether this ToolbarButtonField is enabled or disabled. |
|
void |
setImage(Image image)
Sets the image that is displayed on the ToolbarButtonField . |
|
void |
setText(StringProvider text)
Sets the text to display on the ToolbarButtonField when an image is unavailable. |
|
void |
setTooltip(StringProvider tooltip)
Sest the text that is displayed in the tooltip when the user hovers over this ToolbarButtonField . |
|
boolean |
touchEvent(TouchEvent message)
Indicates a touch event. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ToolbarButtonField()
ToolbarButtonField
with an ordinal of 0.
public ToolbarButtonField(int ordinal)
ToolbarButtonField
with a specified priority order.
ordinal
- The priority order of this ToolbarButtonField
.public ToolbarButtonField(long style)
ToolbarButtonField
with a specified style.
style
- style for this ToolbarButtonField
.public ToolbarButtonField(int ordinal, long style)
ToolbarButtonField
, which a specified order and style.
ordinal
- The priority order of this ToolbarButtonField
.style
- The style for this ToolbarButtonField
.public ToolbarButtonField(StringProvider text)
ToolbarButtonField
with the specified text to use if an
image or tooltip is not provided.
text
- Text to be displayed when the image is not available or a tooltip is not provided.public ToolbarButtonField(StringProvider text, int ordinal)
ToolbarButtonField
with the specified text and ordinal.
text
- Text to be displayed when the image is not available or a tooltip is not provided.ordinal
- The priority order of this ToolbarButtonField
.public ToolbarButtonField(Image image, StringProvider text)
ToolbarButtonField
with the specified image and text.
image
- Image to use on the ToolbarButtonField
.text
- Text to be displayed when the image is not available or a tooltip is not provided.public ToolbarButtonField(Image image, StringProvider text, int ordinal)
ToolbarButtonField
with the specified image, text, and ordinal.
image
- Image to use on the ToolbarButtonField
.text
- Text to be displayed when the image is not available or a tooltip is not provided.ordinal
- The priority order of this ToolbarButtonField
.public ToolbarButtonField(Image image, StringProvider text, int ordinal, long style)
ToolbarButtonField
with the specified style, image, text, and ordinal.
Note that a ToolbarButtonField
is always Field.NON_FOCUSABLE
image
- Image to use on the ToolbarButtonField
.text
- Text to be displayed when the image is not available or a tooltip is not provided.ordinal
- The priority order of this ToolbarButtonField
.style
- The style for this ToolbarButtonField
(supports USE_ALL_WIDTH
).Method Detail |
---|
public Command getCommand()
ToolbarButtonField
instance's associated Command
Command
associated with this ToolbarButtonField
.public Image getImage()
ToolbarButtonField
.
null
if none available.public final int getOrdinal()
ToolbarManager.add(net.rim.device.api.ui.Field)
public int getPreferredHeight()
ToolbarButtonField
(equivalent to the preferred height
of the ToolbarManager
).
getPreferredHeight
in class Field
ToolbarButtonField
.ToolbarManager.getPreferredHeight()
public int getPreferredWidth()
getPreferredWidth
in class Field
public String getText()
ToolbarButtonField
if an image is not available or a tooltip
is not provided.
This will first try to retrieve a localized version of the text if a StringProvider
was used. If that does not exist, it returns a plain String
, if provided. If that also
does not exist, this method returns null
.
ToolbarButtonField
if an image is not available or a tooltip
is not provided, or null
if none exists.public String getTooltip()
ToolbarButtonField
.
This will first try to retrieve a localized version of the text if a StringProvider
was used. If that does not exist, this method returns a plain String
, if provided.
If that also does not exist, this method returns the text returned by ToolbarButtonField.getText()
.
ToolbarButtonField
.public void invoke()
ToolbarButtonField
is clicked on if Command
has been set.
A click is defined as the following sequence of touch events: TouchEvent.DOWN
, TouchEvent.CLICK
,
TouchEvent.UNCLICK
and TouchEvent.UP
.
public boolean isEnabled()
ToolbarButtonField
is enabled.
A disabled toolbar button has a grayed out image (if any) or text and does not have a tooltip. It
cannot be clicked on.
isEnabled
in class Field
True
if the ToolbarButtonField
is enabled, false
otherwise.protected void layout(int width, int height)
layout
in class Field
width
- available width for layoutheight
- available height for layoutprotected void onDisplay()
onDisplay
in class Field
protected void onExposed()
onExposed
in class Field
protected void onObscured()
onObscured
in class Field
public void paint(Graphics g)
ToolbarButtonField
.
The ToolbarButtonField will first try to paint an image, if available.
If none is available, it will paint the provided text, if any. If neither
are available, nothing is painted.
paint
in class Field
g
- Graphics objectpublic final void run()
ToolbarButtonField.invoke()
method if and only if the ToolbarButtonField
is enabled.
run
in interface Runnable
Thread.run()
public void setCommand(Command command)
Command
to invoke when a ToolbarButtonField
is activated.
Also updates the enabled state of the ToolbarButtonField
, depending on whether
the command can execute or not.
command
- Command to execute when this ToolbarButtonField
is clicked.Command.canExecute(java.lang.Object)
public void setCommandContext(Object commandContext)
commandContext
- Command
context to use when the Command instance is executed.
If commandContext is null then this ButtonField instance will be passed to Command methods.public void setEnabled(boolean enabled)
ToolbarButtonField
is enabled or disabled. If a ToolbarButtonField
is enabled, the user can hover over the ToolbarButtonField
to show a tooltip and click
on it. A disabled ToolbarButtonField
is displayed, but a user cannot interact with it.
setEnabled
in class Field
enabled
- If true
to enable the ToolbarButtonField
, false
otherwise.public void setImage(Image image)
ToolbarButtonField
. This method calls
Field.invalidate()
after setting the image.
image
- public void setText(StringProvider text)
ToolbarButtonField
when an image is unavailable.
If no tooltip is set, the text is used as a tooltip.
text
- Text that is displayed on the ToolbarButtonField
.public void setTooltip(StringProvider tooltip)
ToolbarButtonField
.
setTooltip
in class Field
tooltip
- Text to display in the tooltip when the user hovers over this ToolbarButtonField
.public boolean touchEvent(TouchEvent message)
touchEvent
in class Field
message
- TouchEvent
object containing various input parameters
including the event type and touch coordinates.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.