DwtButton: Difference between revisions
mNo edit summary |
No edit summary |
||
(5 intermediate revisions by 2 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>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> === | === <code>setMenu(menuOrCallback, shouldToggle, followIconStyle)</code> === | ||
Line 73: | 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
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
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()