qnx.fuse.ui.buttons.IconButton

IconButton

Properties | Methods | Events | Examples


Packageqnx.fuse.ui.buttons
Classpublic class IconButton
InheritanceIconButton Inheritance Button Inheritance SkinnableComponent Inheritance UIComponent Inheritance flash.display.MovieClip

The IconButton class enables you to place an image centered in a button:

An icon button.



Class information:
BlackBerry 10 Version:   10.0.0
Found in:  qnxui.swc

View the examples

See also

Button
LabelButton
qnx.fuse.ui.display.Icon



Public Properties

 PropertyDefined By
  allowIconToFill : Boolean
Returns true if the icon should grow to fill the avaliable size.
IconButton
  allowSmoothing : Boolean
Gets or sets whether or not the currently visible icon should use bitmap smoothing if the icon is resized by the component.
IconButton
 InheritedcontextActions : Vector.<ActionSet>
Gets or Sets a Vector of ActionSet objects.
UIComponent
 InheritedcontextMultiSelectText : String
Gets or Sets a String to be displayed when showing the Multi Select Context Menu.
UIComponent
  currentIcon : String
Gets or sets the currently visible icon.
IconButton
 InheritedcurrentTheme : String
[read-only] Returns the current theme this component is styled with.
UIComponent
 InheritedexplicitHeight : Number
[read-only] Returns the explicit height (actual height, in pixels) of the UI component.
UIComponent
 InheritedexplicitWidth : Number
[read-only] Returns the explicit width (actual width, in pixels) of the UI component.
UIComponent
 Inheritedid : String
The id is a name for the component that can be used in CSS using the # selector.
UIComponent
 InheritedincludeInLayout : Boolean
Specifies whether or not the component should be included in its parent container's layout.
UIComponent
 InheritedlayoutData : Object
Gets or sets the layoutData.
UIComponent
 Inheritedlocale : String
Gets or sets the current locale of the component.
UIComponent
 InheritedminHeight : Number
Gets or sets the minimum preferred height of the control.
UIComponent
 InheritedminWidth : Number
Gets or sets the minimum preferred width of the control.
UIComponent
  paddingBottom : uint
Sets the number of extra pixels that are added to the bottom of the icon, between the border of the button and the icon.
IconButton
  paddingLeft : uint
Sets the number of extra pixels that are added to the left of the icon, between the border of the button and the icon.
IconButton
  paddingRight : uint
Sets the number of extra pixels that are added to the right of the icon, between the border of the button and the icon.
IconButton
  paddingTop : uint
Sets the number of extra pixels that are added to the top of the icon, between the border of the button and the icon.
IconButton
 Inheritedselected : Boolean
Setting the selected property changes the visual state of the Button to selected.
Button
 Inheritedstate : String
Gets or sets the state of the component.
SkinnableComponent
 InheritedstyleChildren : Boolean
Allows you to style the children of this component with CSS.
UIComponent
 Inheritedtoggle : Boolean
The toggle property allows the button to switch between its selected and released states each time it's tapped.
Button

Protected Properties

 PropertyDefined By
 InheritedaccessibilityImplimentationClass : Class
UIComponent
  cssID : String
[override] [read-only] Returns the CSS ID of the component.
IconButton
 InheritedexplicitLocale : Boolean
Set to true when the locale property has been set externally.
UIComponent
  icon : Icon
The internal representation of the icon.
IconButton
 InheritedinternalID : String
The Component's Id used for styling.
UIComponent
 InheritedlongPressEnabled : Boolean
Specifies whether the UIComponent can detect a long press.
UIComponent

Public Methods

 MethodDefined By
  
Constructs an IconButton instance.
IconButton
 Inherited
Cancels a long press from occuring on the component.
UIComponent
 Inherited
childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner that may affect this object's layout.
UIComponent
 Inherited
configureStyles(styles:Array):void
[override] The SkinnableComponent version styles the component with the base style first, and then styles it with the current state's style.
SkinnableComponent
  
destroy():void
[override] Call this method when you want to have your object collected by the garbage collector.
IconButton
 Inherited
Returns the CSS selector for the object, composing it from its position in the display hierarchy and an optional ID selector.
UIComponent
  
getIconForState(state:String):Bitmap
Returns the stored Bitmap for the given state.
IconButton
 Inherited
Returns the size options for the given control.
UIComponent
 Inherited
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered.
UIComponent
 Inherited
Calling this method results in a call to the components validateProperties() method before the display list is rendered.
UIComponent
 Inherited
measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
This method calls doMeasure() in order to calculate the preferred size of the control.
UIComponent
 Inherited
setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting the explicitWidth and explicitHeight.
UIComponent
  
setIcon(image:Object):void
Sets the image for the icon for all states.
IconButton
  
setIconForState(image:Object, state:String):void
Sets the image for the icon for a given state.
IconButton
 Inherited
setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified by the arguments.
UIComponent
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
setSkin(newSkin:Object):void
Set the skin object on the component for it to render.
SkinnableComponent
 Inherited
updateDefaultLocale(updateChildren:Boolean = true):void
Updates the locale property to be the same as the locale of the device.
UIComponent
 Inherited
Lets a component that contains text know that it should update its font formats as the font settings have changed.
UIComponent
 Inherited
Validates the display list of the component by calling the updateDisplayList().
UIComponent
 Inherited
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary.
UIComponent
 Inherited
Validates the properties of the component by calling the commitProperties() method.
UIComponent

Protected Methods

 MethodDefined By
 Inherited
allowShowContextMenu(target:IEventDispatcher):Boolean
When the user presses on the component this method is called with the object that dispatched the event.
UIComponent
 Inherited
Process properties of the component.
UIComponent
 Inherited
Process the state of the component.
UIComponent
 Inherited
Style the component after the style has changed.
UIComponent
 Inherited
doMeasure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
Performs a measurement on the control, and returns a LayoutMeasurement instance containing the available width and height within the layout.
UIComponent
 Inherited
excemptFromCSSStyling(target:*, property:String = null):void
Exempts a property on an object from being styled by CSS.
UIComponent
 Inherited
flushCache():void
Invoked as part of parentLayoutChanged.
UIComponent
 Inherited
getStyleApplier():Function
A style applier is a method that gets called every time a property from the stylesheet should be applied to the component.
UIComponent
 Inherited
getStyleForState(state:String):IStyleable
A utility method to get the styling information for a given state.
SkinnableComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
Is called when a user is no longer long pressing on the component.
UIComponent
 Inherited
Is called when a user long presses on the component.
UIComponent
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 Inherited
Invalidates the parent's size and display list if includeInLayout property is set to true.
UIComponent
 Inherited
Calling this function will refresh the ContextMenu with whatever actions were set by contextActions.
UIComponent
 Inherited
Shows the context menu if there are contextActions associated with the control.
UIComponent
 Inherited
styleState():void
Style the component after state has changed.
UIComponent
 Inherited
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
Sets the size and position of the children of the component.
UIComponent
 Inherited
updateSkin(unscaledWidth:Number, unscaledHeight:Number):void
Updates the skin's dimensions.
SkinnableComponent

Events

 Event Summary Defined By
 InheritedDispatched when an action in the Context Menu is selected.UIComponent
 InheritedDispatched when the Context Menu has closed to the DISMISSED state.UIComponent
 InheritedDispatched when the ContextMenu is closing to the DISMISSED state.UIComponent
 InheritedDispatched when the Context Menu has opened to the PEEK or EXPANDED state.UIComponent
 InheritedDispatched when the ContextMenu is opening from the DISMISSED state.UIComponent
 InheritedDispatched when the CrossCut multiselect has been canceled.UIComponent

Property Detail

allowIconToFill


allowIconToFill:Boolean

Returns true if the icon should grow to fill the avaliable size.

By default the icon will not grow past its native dimensions unless this flag is true. Use this in conjunction with allowSmoothing to maintain image quality.


Implementation

public function get allowIconToFill():Boolean
public function set allowIconToFill(value:Boolean):void

allowSmoothing


allowSmoothing:Boolean

Gets or sets whether or not the currently visible icon should use bitmap smoothing if the icon is resized by the component.


Implementation

public function get allowSmoothing():Boolean
public function set allowSmoothing(value:Boolean):void

cssID


cssID:String  [read-only]
[override]

Returns the CSS ID of the component. The CSS ID is used for identifying the type of component in CSS.

The default value is IconButton.


Implementation

protected function get cssID():String

currentIcon


currentIcon:String

Gets or sets the currently visible icon. Setting the currentIcon won't replace what is in the Icon's state lookup. Set the currentIcon to a string filename of an image on the filesystem, and it will be loaded and replace the current icon.


Implementation

public function get currentIcon():String
public function set currentIcon(value:String):void

icon


protected var icon:Icon

The internal representation of the icon.

paddingBottom


paddingBottom:uint

Sets the number of extra pixels that are added to the bottom of the icon, between the border of the button and the icon.

The default value is 6.


Implementation

public function get paddingBottom():uint
public function set paddingBottom(value:uint):void

paddingLeft


paddingLeft:uint

Sets the number of extra pixels that are added to the left of the icon, between the border of the button and the icon.

The default value is 6.


Implementation

public function get paddingLeft():uint
public function set paddingLeft(value:uint):void

paddingRight


paddingRight:uint

Sets the number of extra pixels that are added to the right of the icon, between the border of the button and the icon.

The default value is 6.


Implementation

public function get paddingRight():uint
public function set paddingRight(value:uint):void

paddingTop


paddingTop:uint

Sets the number of extra pixels that are added to the top of the icon, between the border of the button and the icon.

The default value is 6.


Implementation

public function get paddingTop():uint
public function set paddingTop(value:uint):void

Constructor Detail

IconButton()


public function IconButton()

Constructs an IconButton instance.

Method Detail

destroy()


override public function destroy():void

Call this method when you want to have your object collected by the garbage collector.

NOTE: This method does not remove the object from memory. Instead, it enables your instance to clean up after itself internally so that it can be garbage-collected.

getIconForState()


public function getIconForState(state:String):Bitmap

Returns the stored Bitmap for the given state.

If no Bitmap has been set for the state using setIconForState, null is returned.

Parameters

state:String — The state to fetch an icon for.

Returns

Bitmap — The Bitmap for the supplied state, or null if none exists.

setIcon()


public function setIcon(image:Object):void

Sets the image for the icon for all states. The image is positioned in the center of the button.

If icons have been mapped to states using setIconForState, a call to setIcon will erase those mappings and all states will be mapped to the provided icon. Subsequent calls to setIconForState will work as expected and set the icon for the provided state.

setIcon takes a path to an image (relative to your application file), a fully qualified class name of a Bitmap in the current ApplicationDomain, a Bitmap instance, or a BitmapData instance. In the following example, a path to an image in the source project is passed into the setIcon method.

myIconButton = new IconButton();
myIconButton.setIcon("assets/icon.gif");
         

In the following example, an image is embedded in a class called Settings. The Settings object is instantiated as the argument for the setIcon() method.

[Embed(source="assets/settings.png")] 
public static var Settings:Class;
myIconButton.setIcon( new Settings() );
         

Parameters

image:Object — The icon to be set. A String representing the URL to an external image, a Bitmap instance, or a BitmapData instance.

setIconForState()


public function setIconForState(image:Object, state:String):void

Sets the image for the icon for a given state.

If the state of the component is changed and no icon is mapped to that state, then the icon mapped to SkinStates.UP is used.

setIconForState takes a path to an image (relative to your application file), a fully qualified class name of a Bitmap in the current ApplicationDomain, a Bitmap instance, or a BitmapData instance. In the following example, a path to an image in the source project is passed into the setIconForState method.

myIconButton = new IconButton();
myIconButton.setIconForState("assets/icon.gif", SkinStates.UP);
         

In the following example, an image is embedded in a class called Settings. The Settings object is instantiated as the argument for the setIcon() method.

[Embed(source="assets/settings.png")] 
public static var Settings:Class;
myIconButton.setIconForState(new Settings(), SkinStates.UP);
         

Parameters

image:Object — The icon to be set. Valid objects are either a String representing the URL to an external image, a Bitmap instance, or a BitmapData instance.
state:String (default = NaN)

Examples

In the following example, a .png is displayed in an IconButton instance.

package
{
    import flash.display.Sprite;
    import flash.filesystem.File;
    
    import qnx.fuse.ui.buttons.IconButton;
    import qnx.fuse.ui.buttons.Button;
    import qnx.locale.LocaleManager;
    
    [SWF(height="600", width="1024", frameRate="30", backgroundColor="#FFFFFF")]
    public class ButtonTest extends Sprite
    {
        private var myIconButton:IconButton;
            
        public function ButtonTest()
        {
            initializeIconButton();
        }
            
        private function initializeIconButton():void
        {
            myIconButton = new IconButton();
            myIconButton.setIcon( "icons/icon.png");
            myIconButton.width = 100;
            myIconButton.setPosition(30, 30);
                    
            this.addChild(myIconButton);
        }
    }
}
     




comments powered by Disqus