|
Class: ButtonController
Object
|
+--Controller
|
+--ButtonController
|
+--LinkButtonController
|
+--PointFromUserController
|
+--PopUpListController
|
+--RectangleFromUserController
|
+--ToggleController
- Package:
- stx:libwidg
- Category:
- Interface-Support-Controllers
- Version:
- rev:
1.96
date: 2024/02/23 11:31:28
- user: cg
- file: ButtonController.st directory: libwidg
- module: stx stc-classLibrary: libwidg
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)
copyrightCOPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
defaults
-
defaultInitialDelay
-
when autorepeat is enabled, and button is not released,
start repeating after initialDelay seconds
-
defaultRepeatDelay
-
when autorepeat is enabled, and button is not released,
repeat every repeatDelay seconds
accessing-behavior
-
action
-
-
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.
-
autoRepeat
-
turn on autorepeat. OBSOLETE; use #autoRepeat:
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
autoRepeat: aBoolean
-
turn on/off autorepeat
-
beButton
-
make the receiver act like a button; that's the default, anyway
-
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)
-
beToggle
-
make the receiver act like a toggle
-
beTriggerOnDown
-
make the receiver act on button press
-
beTriggerOnUp
-
make the receiver act on button release
-
disable
-
alternative invokation; redirected to basic mechanism
-
doubleClickAction
-
return the doubleClickAction; that's the block which gets evaluated
when the button is double-clicked (if non-nil).
Seldom used with buttons
-
doubleClickAction: aBlock
-
define the action to be performed on double click
-
enable
-
alternative invokation; redirected to basic mechanism
-
enabled: aBoolean
-
disable the button
-
isAutoRepeat
-
-
isTriggerOnDown
-
return true, if I trigger on press
(in contrast to triggering on up, which is the default)
-
pressAction
-
return the pressAction; that's the block which gets evaluated
when the button is pressed (if non-nil)
-
pressAction: aBlock
-
define the action to be performed on press
-
releaseAction
-
return the releaseAction; that's the block which gets evaluated
when the button is released (if non-nil)
-
releaseAction: aBlock
-
define the action to be performed on release
-
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
-
enableChannel
-
return the valueHolder holding the enable boolean value
-
enableChannel: aValueHolder
-
set the valueHolder, which holds the enable boolean value
-
pressChannel
-
-
pressChannel: aChannel
-
-
releaseChannel
-
-
releaseChannel: aChannel
-
accessing-state
-
active
-
return true, if I am active;
that is: currently performing my action.
This query can be used to avoid multiple redraws.
-
active: aBoolean
-
-
enabled
-
return true, if I am enabled
-
entered
-
return true, if the mouse pointer is currently in my view
-
entered: aBoolean
-
-
pressed
-
return true, if I am pressed
-
pressed: aBoolean
-
-
setPressed: aBoolean
-
-
toggle
-
toggle and perform the action
-
toggleNoAction
-
toggle, but do NOT perform any action
event handling
-
buttonMotion: buttonState x: x y: y
-
(comment from inherited method)
mouse was moved with button pressed in my view; nothing done here
-
buttonMultiPress: button x: x y: y
-
(comment from inherited method)
a mouse button was pressed again shortly after in my view
-
buttonPress: button x: x y: y
-
simulate momentary loss of focus to force accept into models in other components
-
buttonRelease: button x: x y: y
-
button was released - if enabled, perform releaseaction
-
enableStateChanged
-
this is sent, whenever the enable value has changed
-
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)
-
performAction
-
ST-80 style model notification ...
this updates the model (typically, a ValueHolder)
-
performShortcutAction
-
-
pointerEnter: state x: x y: y
-
mouse pointer entered my view.
Redraw with enteredColors if they differ from the normal colors
-
pointerLeave: state
-
mouse pointer left my view.
Redraw with normal colors if they differ from enteredColors
-
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 ...
|
-
requestAutoAccept
-
request to autoAccept from a keyboardProcessor.
AutoAccept is always allowed
initialization
-
controlInitialize
-
-
initialize
-
must be called if redefined
-
reinitialize
-
-
release
-
release all dependencies
|