eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ButtonController':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ButtonController


Inheritance:

   Object
   |
   +--Controller
      |
      +--ButtonController
         |
         +--LinkButtonController
         |
         +--PointFromUserController
         |
         +--PopUpListController
         |
         +--RectangleFromUserController
         |
         +--ToggleController

Package:
stx:libwidg
Category:
Interface-Support-Controllers
Version:
rev: 1.85 date: 2017/02/07 23:57:16
user: cg
file: ButtonController.st directory: libwidg
module: stx stc-classLibrary: libwidg
Author:
Claus Gittinger

Description:


ButtonControllers are used with buttons and handle all user interaction.
These are automatically created when a Button is created, therefore no manual
action is required for creation.
In normal applications, you don't have to care for the controller; 
access to the controllers behavior is possible via messages to the button.
(setting actions, controlling autorepeat etc.)

A ButtonController supports 3 types of notifications:
    MVC change notification - as usual
    channel notifications   - through the pressChannel/releaseChannels
    action callBack         - through pressAction / releaseAction blocks.

Notifications are made in the above order (i.e. an actionBlock sees the model
already changed, if there is a model).

Having multiple mechanisms here is both historic and to make the life
of simple applications easier - most buttons don't need a model or notification
channels and simply perform some action.
In general: actionBlocks are useful, if there is a single subject which
needs to be told about the press (i.e. actionButtons); 
models should be used when the button represents some value in some other
object.
Channels are much like the MVC approach, however, these are useful if
press/release/label etc. may come from different objects, and a single 
(synthetic) model does not make sense or is not appropriate.

Actually, the channels are the most general - and the other mechanism could
(and will, maybe) based upon them; after all, an actionBlock is a channel,
whcih sends #value to its block ....



See examples in the Button class.

[Instance variables:]

  enableChannel           <ValueHolder    pressing is allowed (default: true)
                           on Boolean>    

  pressed                 <Boolean>       true if currently pressed (read-only)

  entered                 <Boolean>       true if the cursor is currently in this view

  isTriggerOnDown         <Boolean>       controls if the action should be executed on
                                          press or on release (default: on release).

  isToggle                <Boolean>       controls if the button should show toggle
                                          behavior (as opposed to one-shot behavior)

  pressActionBlock        <Block>         block to evaluate when pressed (default: noop)

  releaseActionBlock      <Block>         block to evaluate when released (default: noop)

  autoRepeat              <Boolean>       auto-repeats when pressed long enough (default: false)

  initialDelay            <Number>        seconds till first auto-repeat (default: 0.2)

  repeatDelay             <Number>        seconds of repeat intervall (default: 0.025)

  repeatBlock             <Block>         block evaluated for auto-repeat (internal)

  active                  <Boolean>       true during action evaluation (internal)


Class protocol:

defaults
o  defaultInitialDelay
when autorepeat is enabled, and button is not released,
start repeating after initialDelay seconds

o  defaultRepeatDelay
when autorepeat is enabled, and button is not released,
repeat every repeatDelay seconds


Instance protocol:

accessing-behavior
o  action: aBlock
convenient method: depending on the setting the triggerOnDown flag,
either set the press-action & clear any release-action or
vice versa, set the release-action and clear the press-action.

o  autoRepeat
turn on autorepeat. OBSOLETE; use #autoRepeat:

o  autoRepeat: aBoolean
turn on/off autorepeat

o  beButton
make the receiver act like a button; that's the default, anyway

o  beRadioButton
make the receiver act like a radioButton;
That is like a toggle, but do not allow turning myself off
by buttonPress (instead, must be turned off by another button or programmatically)

o  beToggle
make the receiver act like a toggle

o  beTriggerOnDown
make the receiver act on button press

o  beTriggerOnUp
make the receiver act on button release

o  disable
alternative invokation; redirected to basic mechanism

o  doubleClickAction
return the doubleClickAction; that's the block which gets evaluated
when the button is double-clicked (if non-nil).
Seldom used with buttons

o  doubleClickAction: aBlock
define the action to be performed on double click

o  enable
alternative invokation; redirected to basic mechanism

o  enabled: aBoolean
disable the button

o  isTriggerOnDown
return true, if I trigger on press
(in contrast to triggering on up, which is the default)

o  pressAction
return the pressAction; that's the block which gets evaluated
when the button is pressed (if non-nil)

o  pressAction: aBlock
define the action to be performed on press

o  releaseAction
return the releaseAction; that's the block which gets evaluated
when the button is released (if non-nil)

o  releaseAction: aBlock
define the action to be performed on release

o  triggerOnDown: aBoolean
set/clear the flag which controls if the action block is to be evaluated
on press or on release.
(see also ST-80 compatibility methods beTriggerOn*)

accessing-channels
o  enableChannel
return the valueHolder holding the enable boolean value

o  enableChannel: aValueHolder
set the valueHolder, which holds the enable boolean value

o  pressChannel

o  pressChannel: aChannel

o  releaseChannel

o  releaseChannel: aChannel

accessing-state
o  active
return true, if I am active;
that is: currently performing my action.
This query can be used to avoid multiple redraws.

o  active: aBoolean

o  enabled
return true, if I am enabled

o  entered
return true, if the mouse pointer is currently in my view

o  entered: aBoolean

o  pressed
return true, if I am pressed

o  pressed: aBoolean

o  setPressed: aBoolean

o  toggle
toggle and perform the action

o  toggleNoAction
toggle, but do NOT perform any action

event handling
o  buttonMotion: buttonState x: x y: y

o  buttonMultiPress: button x: x y: y

o  buttonPress: button x: x y: y
simulate momentary loss of focus to force accept into models in other components

o  buttonRelease: button x: x y: y
button was released - if enabled, perform releaseaction

o  enableStateChanged
this is sent, whenever the enable value has changed

o  keyPress: key x: x y: y
trigger on Return and space, if I am the focusView of my group
(i.e. if I got an explicit focus)

o  performAction
ST-80 style model notification ...
this updates the model (typically, a ValueHolder)

o  performShortcutAction

o  pointerEnter: state x: x y: y
mouse pointer entered my view.
Redraw with enteredColors if they differ from the normal colors

o  pointerLeave: state
mouse pointer left my view.
Redraw with normal colors if they differ from enteredColors

o  repeat
this is sent from the autorepeat-block, when the button has been pressed long
enough; it simulates a release-press, by evaluating both release
and press actions.
usage example(s):
don't repeat, if a release is pending ...

o  requestAutoAccept
request to autoAccept from a keyboardProcessor.
AutoAccept is always allowed

initialization
o  controlInitialize

o  initialize
must be called if redefined

o  reinitialize

o  release
release all dependencies



ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Tue, 20 Nov 2018 16:34:56 GMT