DwtButton: Difference between revisions

mNo edit summary
No edit summary
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Zimbra AjaxTk]]->[[DHTML Widget Toolkit]]->[[Widgets]]
{{Archive}}[[Zimbra AjaxTk]]->[[DHTML Widget Toolkit]]->[[Widgets]]
----
----
==Preview==
[[Image:DwtButton.JPG]]
==Usage==
<code>
function createButton(name){
    var l = new AjxListener(null, buttonListener);
    var b = new DwtButton(shell);
    b.addSelectionListener(l);
    b.setText(name);
}
function buttonListener(ev) {
    alert("Button Pressed: " + ev.item.getText());
}
</code>


==Methods==
==Methods==
<code>setMenu(menuOrCallback, shouldToggle, followIconStyle)</code>
=== <code>DwtButton(parent, style, className, posStyle, actionTiming) </code> ===
This class represents a button, which is basically a smart label that can handle
various UI events. It knows when it has been activated (the mouse is over it),
when it has been triggered (mouse down), and when it has been pressed (mouse up).
In addition to a label's image and/or text, a button may have a dropdown menu.
;<code>parent</code>    : the parent widget
;<code>style</code>      : the label style (see DwtLabel)
;<code>className</code>  : a CSS class for look and feel, defaults to "DwtButton" class
;<code>posStyle</code>  : HTML positioning style - Static, Absolute, Relative
;<code>actionTiming</code>: Sets whether actions for this button should occur on mouse up or mouse down
 
=== <code>setMenu(menuOrCallback, shouldToggle, followIconStyle)</code> ===


Adds a dropdown menu to the button, available through a small down-arrow.
Adds a dropdown menu to the button, available through a small down-arrow.
Line 10: Line 38:
;<code>followIconStyle</code>  : style of menu item (should be checked or radio style) for which the button icon should reflect the menu item icon
;<code>followIconStyle</code>  : style of menu item (should be checked or radio style) for which the button icon should reflect the menu item icon


addSelectionListener(listener)
=== <code>addSelectionListener(listener)</code> ===


removeSelectionListener(listener)
=== <code>removeSelectionListener(listener)</code> ===
Removes a selection listener.
Removes a selection listener.
;<code>listener</code> : the listener to remove
;<code>listener</code> : the listener to remove


removeSelectionListeners()
=== <code>removeSelectionListeners()</code> ===
Removes all the selection listeners.
Removes all the selection listeners.




addDropDownSelectionListener(listener)
=== <code>addDropDownSelectionListener(listener)</code> ===
Adds a listener to be notified when the dropdown arrow is pressed.
Adds a listener to be notified when the dropdown arrow is pressed.
;<code>listener</code> : a listener
;<code>listener</code> : a listener


removeDropDownSelectionListener(listener)
=== <code>removeDropDownSelectionListener(listener)</code> ===
Removes a dropdown selection listener.
Removes a dropdown selection listener.
;<code>listener</code> : the listener to remove
;<code>listener</code> : the listener to remove


setDropDownImages(enabledImg, disImg, hovImg, depImg)
=== <code>setDropDownImages(enabledImg, disImg, hovImg, depImg)</code> ===




setEnabled(enabled)
=== <code>setEnabled(enabled)</code> ===
Sets the enabled/disabled state of the button. A disabled button may have a different image, and greyed out text. The button (and its menu) will only have listeners if it is enabled.
Sets the enabled/disabled state of the button. A disabled button may have a different image, and greyed out text. The button (and its menu) will only have listeners if it is enabled.
;<code>enabled</code> : whether to enable the button
;<code>enabled</code> : whether to enable the button


setHoverImage(hoverImageInfo)
=== <code>setHoverImage(hoverImageInfo)</code> ===
;<code>hoverImageInfo</code> :


setMenu(menuOrCallback, shouldToggle, followIconStyle)
setMenu(menuOrCallback, shouldToggle, followIconStyle)
Line 58: Line 87:
;<code>activated</code> : whether the button is activated
;<code>activated</code> : whether the button is activated


<code>setEnabledImage(imageInfo)</code>
=== <code>setEnabledImage(imageInfo)</code> ===
;<code>imageInfo</code> :  
;<code>imageInfo</code> :  


Line 72: Line 101:
trigger()
trigger()
deactivate()
deactivate()
{{Article Footer|unknown|4/15/2006}}
[[Category:Zimbra AjaxTk]]

Latest revision as of 12:29, 24 March 2015

Zimbra AjaxTk->DHTML Widget Toolkit->Widgets


Preview

DwtButton.JPG

Usage

function createButton(name){

   var l = new AjxListener(null, buttonListener);
   var b = new DwtButton(shell);
   b.addSelectionListener(l);
   b.setText(name);

}


function buttonListener(ev) {

   alert("Button Pressed: " + ev.item.getText());

}


Methods

DwtButton(parent, style, className, posStyle, actionTiming)

This class represents a button, which is basically a smart label that can handle various UI events. It knows when it has been activated (the mouse is over it), when it has been triggered (mouse down), and when it has been pressed (mouse up). In addition to a label's image and/or text, a button may have a dropdown menu.

parent
the parent widget
style
the label style (see DwtLabel)
className
a CSS class for look and feel, defaults to "DwtButton" class
posStyle
HTML positioning style - Static, Absolute, Relative
actionTiming
Sets whether actions for this button should occur on mouse up or mouse down

setMenu(menuOrCallback, shouldToggle, followIconStyle)

Adds a dropdown menu to the button, available through a small down-arrow.

menuOrCallback
The dropdown menu or an AjxCallback object. If a callback is given, it is called the first time the menu is requested. The callback must return a valid DwtMenu object.
shouldToggle
followIconStyle
style of menu item (should be checked or radio style) for which the button icon should reflect the menu item icon

addSelectionListener(listener)

removeSelectionListener(listener)

Removes a selection listener.

listener
the listener to remove

removeSelectionListeners()

Removes all the selection listeners.


addDropDownSelectionListener(listener)

Adds a listener to be notified when the dropdown arrow is pressed.

listener
a listener

removeDropDownSelectionListener(listener)

Removes a dropdown selection listener.

listener
the listener to remove

setDropDownImages(enabledImg, disImg, hovImg, depImg)

setEnabled(enabled)

Sets the enabled/disabled state of the button. A disabled button may have a different image, and greyed out text. The button (and its menu) will only have listeners if it is enabled.

enabled
whether to enable the button

setHoverImage(hoverImageInfo)

hoverImageInfo

setMenu(menuOrCallback, shouldToggle, followIconStyle) Adds a dropdown menu to the button, available through a small down-arrow.

menuOrCallback
The dropdown menu or an AjxCallback object. If a callback is given, it is called the first time the menu is requested. The callback must return a valid DwtMenu object.
shouldToggle
followIconStyle
style of menu item (should be checked or radio style) for which the button icon should reflect the menu item icon


getMenu() Returns the button's menu

resetClassName() Returns the button display to normal (not activated or triggered).

setActionTiming(actionTiming) Sets whether actions for this button should occur on mouse up or mouse down.

actionTiming
Currently supports DwtButton.ACTION_MOUSEDOWN and DwtButton.ACTION_MOUSEUP

setActivated(activated) Activates/inactivates the button. A button is activated when the mouse is over it.

activated
whether the button is activated

setEnabledImage(imageInfo)

imageInfo

setDepressedImage(imageInfo)

setToggled(toggled)

isToggled()

popup()


trigger() deactivate()


Verified Against: unknown Date Created: 4/15/2006
Article ID: https://wiki.zimbra.com/index.php?title=DwtButton Date Modified: 2015-03-24



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »

Jump to: navigation, search