Zebra API Doc

zebra.ui.Button Class

Button UI component. Button is composite component whose look and feel can be easily customized:

  // create image button
  var button = new zebra.ui.Button(new zebra.ui.ImagePan("icon1.gif"));

  // create image + caption button 
  var button = new zebra.ui.Button(new zebra.ui.ImageLabel("Caption", "icon1.gif"));

  // create multilines caption button  
  var button = new zebra.ui.Button(new zebra.ui.MLabel("Line1\nLine2"));

Constructor

zebra.ui.Button

(
  • [t]
)

Parameters:

  • [t] String | zebra.ui.Panel optional

    a button label. The label can be a simple text or an UI component.

Methods

catchInput

(
  • c
)
Boolean

Inherited from zebra.ui.Composite:

The method is called to ask if the given children UI component has to be input events transparent

Parameters:


Return: Boolean

true if the given children component has to be input events transparent

run

() protected

The method is executed for a button that is configured to repeat fire events.

setCanHaveFocus

(
  • b
)

Says if the component can hold focus or not

Parameters:

  • b Boolean

    true if the component can gain focus

setFireParams

(
  • b
  • time
)

Set the mode the button has to fire events. Button can fire event after it has been unpressed or immediately when it has been pressed. Also button can start firing events periodically when it has been pressed and held in the pressed state.

Parameters:

  • b Boolean

    true if the button has to fire event by pressed event

  • time Integer

    the period of time the button has to repeat firing events if it has been pressed and held in pressed state. -1 means event doesn't have repeated

setFocusAnchorComponent

(
  • c
)

Set the specified children component to be used as focus marker view anchor component. Anchor component is a component over that the focus marker view is painted.

Parameters:

setFocusMarkerView

(
  • c
)

Set the view that has to be rendered as focus marker when the component gains focus.

Parameters:

  • c String | zebra.ui.View | Function

    a view. The view can be a color or border string code or view or an implementation of zebra.ui.View "paint(g,x,y,w,h,t)" method.

Attributes

canHaveFocus

Boolean readonly

Indicates if the component can have focus

firePeriod

Integer readonly

Fire button event repeating period. -1 means the button event repeating is disabled.

Default: -1

focusMarkerView

zebra.ui.Panel readonly

Reference to an anchor focus marker component

isFireByPress

Boolean readonly

Indicate if the button should fire event by pressed event

Default: false

Events

buttonPressed

Fired when a button has been pressed

   var b = new zebra.ui.Button("Test");
   b.bind(function (src) {
       ...
   });

Button can be adjusted in respect how it generates the pressed event. Event can be triggered by pressed or clicked even. Also event can be generated periodically if the button is kept in pressed state.

Event Parameters: