Difference between revisions of "DwtButton"

 
 
(16 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{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==
 +
=== <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.
 +
;<code>menuOrCallback</code> :  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.
 +
;<code>shouldToggle</code> :
 +
;<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>addSelectionListener(listener)</code> ===
 +
 +
=== <code>removeSelectionListener(listener)</code> ===
 +
Removes a selection listener.
 +
;<code>listener</code> : the listener to remove
 +
 +
=== <code>removeSelectionListeners()</code> ===
 +
Removes all the selection listeners.
 +
 +
 +
=== <code>addDropDownSelectionListener(listener)</code> ===
 +
Adds a listener to be notified when the dropdown arrow is pressed.
 +
;<code>listener</code> : a listener
 +
 +
=== <code>removeDropDownSelectionListener(listener)</code> ===
 +
Removes a dropdown selection listener.
 +
;<code>listener</code> : the listener to remove
 +
 +
=== <code>setDropDownImages(enabledImg, disImg, hovImg, depImg)</code> ===
 +
 +
 +
=== <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.
 +
;<code>enabled</code> : whether to enable the button
 +
 +
=== <code>setHoverImage(hoverImageInfo)</code> ===
 +
;<code>hoverImageInfo</code> :
  
Methods
 
 
setMenu(menuOrCallback, shouldToggle, followIconStyle)
 
setMenu(menuOrCallback, shouldToggle, followIconStyle)
 
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.
* @param menuOrCallback The dropdown menu or an AjxCallback object. If a
+
;<code>menuOrCallback</code> : 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.
                          callback is given, it is called the first time the
+
;<code>shouldToggle</code> :
                          menu is requested. The callback must return a valid  
+
;<code>followIconStyle</code> : style of menu item (should be checked or radio style) for which the button icon should reflect the menu item icon
                          DwtMenu object.
+
 
* @param shouldToggle
+
 
* @param followIconStyle style of menu item (should be checked or radio style) for
+
getMenu()
* which the button icon should reflect the menu item icon
+
Returns the button's menu
*/
+
 
DwtButton.prototype.setMenu =
+
resetClassName()
function(menuOrCallback, shouldToggle, followIconStyle)
+
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.
 +
;<code>actionTiming</code> : 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.
 +
;<code>activated</code> : whether the button is activated
 +
 
 +
=== <code>setEnabledImage(imageInfo)</code> ===
 +
;<code>imageInfo</code> :
 +
 
 +
setDepressedImage(imageInfo)
 +
 
 +
setToggled(toggled)
 +
 
 +
isToggled()
 +
 
 +
popup()
 +
 
 +
 
 +
trigger()
 +
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