Copyright | Will Thompson, Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (garetxe@gmail.com) |
Safe Haskell | None |
Language | Haskell2010 |
A ToggleButton
is a Button
which will remain “pressed-in” when
clicked. Clicking again will cause the toggle button to return to its
normal state.
A toggle button is created by calling either toggleButtonNew
or
toggleButtonNewWithLabel
. If using the former, it is advisable to
pack a widget, (such as a Label
and/or a Image
), into the toggle
button’s container. (See Button
for more information).
The state of a ToggleButton
can be set specifically using
toggleButtonSetActive
, and retrieved using
toggleButtonGetActive
.
To simply switch the state of a toggle button, use toggleButtonToggled
.
CSS nodes
GtkToggleButton has a single CSS node with name button. To differentiate
it from a plain Button
, it gets the .toggle style class.
## Creating two ToggleButton
widgets.
C code
void make_toggles (void) { GtkWidget *dialog, *toggle1, *toggle2; GtkWidget *content_area; const char *text; dialog = gtk_dialog_new (text); content_area = gtk_dialog_get_content_area (); text = "Hi, i’m a toggle button."; toggle1 = gtk_toggle_button_new_with_label (text); // Makes this toggle button invisible gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle1), TRUE); g_signal_connect (toggle1, "toggled", G_CALLBACK (output_state), NULL); gtk_box_pack_start (GTK_BOX (content_area), toggle1, FALSE, FALSE, 2); text = "Hi, i’m a toggle button."; toggle2 = gtk_toggle_button_new_with_label (text); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (toggle2), FALSE); g_signal_connect (toggle2, "toggled", G_CALLBACK (output_state), NULL); gtk_box_pack_start (GTK_BOX (content_area), toggle2, FALSE, FALSE, 2); gtk_widget_show_all (dialog); }
- newtype ToggleButton = ToggleButton (ManagedPtr ToggleButton)
- class GObject o => IsToggleButton o
- toToggleButton :: IsToggleButton o => o -> IO ToggleButton
- noToggleButton :: Maybe ToggleButton
- data ToggleButtonGetActiveMethodInfo
- toggleButtonGetActive :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> m Bool
- data ToggleButtonGetInconsistentMethodInfo
- toggleButtonGetInconsistent :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> m Bool
- data ToggleButtonGetModeMethodInfo
- toggleButtonGetMode :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> m Bool
- toggleButtonNew :: (HasCallStack, MonadIO m) => m ToggleButton
- toggleButtonNewWithLabel :: (HasCallStack, MonadIO m) => Text -> m ToggleButton
- toggleButtonNewWithMnemonic :: (HasCallStack, MonadIO m) => Text -> m ToggleButton
- data ToggleButtonSetActiveMethodInfo
- toggleButtonSetActive :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> Bool -> m ()
- data ToggleButtonSetInconsistentMethodInfo
- toggleButtonSetInconsistent :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> Bool -> m ()
- data ToggleButtonSetModeMethodInfo
- toggleButtonSetMode :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> Bool -> m ()
- data ToggleButtonToggledMethodInfo
- toggleButtonToggled :: (HasCallStack, MonadIO m, IsToggleButton a) => a -> m ()
- data ToggleButtonActivePropertyInfo
- constructToggleButtonActive :: IsToggleButton o => Bool -> IO (GValueConstruct o)
- getToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> m Bool
- setToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> Bool -> m ()
- toggleButtonActive :: AttrLabelProxy "active"
- data ToggleButtonDrawIndicatorPropertyInfo
- constructToggleButtonDrawIndicator :: IsToggleButton o => Bool -> IO (GValueConstruct o)
- getToggleButtonDrawIndicator :: (MonadIO m, IsToggleButton o) => o -> m Bool
- setToggleButtonDrawIndicator :: (MonadIO m, IsToggleButton o) => o -> Bool -> m ()
- toggleButtonDrawIndicator :: AttrLabelProxy "drawIndicator"
- data ToggleButtonInconsistentPropertyInfo
- constructToggleButtonInconsistent :: IsToggleButton o => Bool -> IO (GValueConstruct o)
- getToggleButtonInconsistent :: (MonadIO m, IsToggleButton o) => o -> m Bool
- setToggleButtonInconsistent :: (MonadIO m, IsToggleButton o) => o -> Bool -> m ()
- toggleButtonInconsistent :: AttrLabelProxy "inconsistent"
- type C_ToggleButtonToggledCallback = Ptr () -> Ptr () -> IO ()
- type ToggleButtonToggledCallback = IO ()
- data ToggleButtonToggledSignalInfo
- afterToggleButtonToggled :: (GObject a, MonadIO m) => a -> ToggleButtonToggledCallback -> m SignalHandlerId
- genClosure_ToggleButtonToggled :: ToggleButtonToggledCallback -> IO Closure
- mk_ToggleButtonToggledCallback :: C_ToggleButtonToggledCallback -> IO (FunPtr C_ToggleButtonToggledCallback)
- noToggleButtonToggledCallback :: Maybe ToggleButtonToggledCallback
- onToggleButtonToggled :: (GObject a, MonadIO m) => a -> ToggleButtonToggledCallback -> m SignalHandlerId
- wrap_ToggleButtonToggledCallback :: ToggleButtonToggledCallback -> Ptr () -> Ptr () -> IO ()
Exported types
newtype ToggleButton Source #
GObject ToggleButton Source # | |
IsImplementorIface ToggleButton Source # | |
IsObject ToggleButton Source # | |
IsWidget ToggleButton Source # | |
IsToggleButton ToggleButton Source # | |
IsContainer ToggleButton Source # | |
IsButton ToggleButton Source # | |
IsBin ToggleButton Source # | |
IsBuildable ToggleButton Source # | |
IsActivatable ToggleButton Source # | |
IsActionable ToggleButton Source # | |
((~) * info (ResolveToggleButtonMethod t ToggleButton), MethodInfo * info ToggleButton p) => IsLabel t (ToggleButton -> p) Source # | |
((~) * info (ResolveToggleButtonMethod t ToggleButton), MethodInfo * info ToggleButton p) => IsLabelProxy t (ToggleButton -> p) Source # | |
HasAttributeList * ToggleButton Source # | |
type AttributeList ToggleButton Source # | |
type SignalList ToggleButton Source # | |
class GObject o => IsToggleButton o Source #
toToggleButton :: IsToggleButton o => o -> IO ToggleButton Source #
Methods
getActive
data ToggleButtonGetActiveMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsToggleButton a) => MethodInfo * ToggleButtonGetActiveMethodInfo a signature Source # | |
toggleButtonGetActive Source #
:: (HasCallStack, MonadIO m, IsToggleButton a) | |
=> a |
|
-> m Bool | Returns: a |
Queries a ToggleButton
and returns its current state. Returns True
if
the toggle button is pressed in and False
if it is raised.
getInconsistent
data ToggleButtonGetInconsistentMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsToggleButton a) => MethodInfo * ToggleButtonGetInconsistentMethodInfo a signature Source # | |
toggleButtonGetInconsistent Source #
:: (HasCallStack, MonadIO m, IsToggleButton a) | |
=> a |
|
-> m Bool | Returns: |
Gets the value set by toggleButtonSetInconsistent
.
getMode
data ToggleButtonGetModeMethodInfo Source #
((~) * signature (m Bool), MonadIO m, IsToggleButton a) => MethodInfo * ToggleButtonGetModeMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsToggleButton a) | |
=> a |
|
-> m Bool | Returns: |
Retrieves whether the button is displayed as a separate indicator
and label. See toggleButtonSetMode
.
new
:: (HasCallStack, MonadIO m) | |
=> m ToggleButton | Returns: a new toggle button. |
Creates a new toggle button. A widget should be packed into the button, as in buttonNew
.
newWithLabel
toggleButtonNewWithLabel Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m ToggleButton | Returns: a new toggle button. |
Creates a new toggle button with a text label.
newWithMnemonic
toggleButtonNewWithMnemonic Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m ToggleButton | Returns: a new |
Creates a new ToggleButton
containing a label. The label
will be created using labelNewWithMnemonic
, so underscores
in label
indicate the mnemonic for the button.
setActive
data ToggleButtonSetActiveMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsToggleButton a) => MethodInfo * ToggleButtonSetActiveMethodInfo a signature Source # | |
toggleButtonSetActive Source #
:: (HasCallStack, MonadIO m, IsToggleButton a) | |
=> a |
|
-> Bool | |
-> m () |
Sets the status of the toggle button. Set to True
if you want the
GtkToggleButton to be “pressed in”, and False
to raise it.
This action causes the ToggleButton
::toggled
signal and the
Button
::clicked
signal to be emitted.
setInconsistent
data ToggleButtonSetInconsistentMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsToggleButton a) => MethodInfo * ToggleButtonSetInconsistentMethodInfo a signature Source # | |
toggleButtonSetInconsistent Source #
:: (HasCallStack, MonadIO m, IsToggleButton a) | |
=> a |
|
-> Bool |
|
-> m () |
If the user has selected a range of elements (such as some text or
spreadsheet cells) that are affected by a toggle button, and the
current values in that range are inconsistent, you may want to
display the toggle in an “in between” state. This function turns on
“in between” display. Normally you would turn off the inconsistent
state again if the user toggles the toggle button. This has to be
done manually, toggleButtonSetInconsistent
only affects
visual appearance, it doesn’t affect the semantics of the button.
setMode
data ToggleButtonSetModeMethodInfo Source #
((~) * signature (Bool -> m ()), MonadIO m, IsToggleButton a) => MethodInfo * ToggleButtonSetModeMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsToggleButton a) | |
=> a |
|
-> Bool |
|
-> m () |
Sets whether the button is displayed as a separate indicator and label.
You can call this function on a checkbutton or a radiobutton with
drawIndicator
= False
to make the button look like a normal button.
This can be used to create linked strip of buttons that work like
a StackSwitcher
.
This function only affects instances of classes like CheckButton
and RadioButton
that derive from ToggleButton
,
not instances of ToggleButton
itself.
toggled
data ToggleButtonToggledMethodInfo Source #
((~) * signature (m ()), MonadIO m, IsToggleButton a) => MethodInfo * ToggleButtonToggledMethodInfo a signature Source # | |
:: (HasCallStack, MonadIO m, IsToggleButton a) | |
=> a |
|
-> m () |
Emits the ToggleButton
::toggled
signal on the
ToggleButton
. There is no good reason for an
application ever to call this function.
Properties
active
data ToggleButtonActivePropertyInfo Source #
constructToggleButtonActive :: IsToggleButton o => Bool -> IO (GValueConstruct o) Source #
getToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> m Bool Source #
setToggleButtonActive :: (MonadIO m, IsToggleButton o) => o -> Bool -> m () Source #
toggleButtonActive :: AttrLabelProxy "active" Source #
drawIndicator
data ToggleButtonDrawIndicatorPropertyInfo Source #
constructToggleButtonDrawIndicator :: IsToggleButton o => Bool -> IO (GValueConstruct o) Source #
getToggleButtonDrawIndicator :: (MonadIO m, IsToggleButton o) => o -> m Bool Source #
setToggleButtonDrawIndicator :: (MonadIO m, IsToggleButton o) => o -> Bool -> m () Source #
toggleButtonDrawIndicator :: AttrLabelProxy "drawIndicator" Source #
inconsistent
data ToggleButtonInconsistentPropertyInfo Source #
constructToggleButtonInconsistent :: IsToggleButton o => Bool -> IO (GValueConstruct o) Source #
getToggleButtonInconsistent :: (MonadIO m, IsToggleButton o) => o -> m Bool Source #
setToggleButtonInconsistent :: (MonadIO m, IsToggleButton o) => o -> Bool -> m () Source #
toggleButtonInconsistent :: AttrLabelProxy "inconsistent" Source #
Signals
toggled
type ToggleButtonToggledCallback = IO () Source #
afterToggleButtonToggled :: (GObject a, MonadIO m) => a -> ToggleButtonToggledCallback -> m SignalHandlerId Source #
mk_ToggleButtonToggledCallback :: C_ToggleButtonToggledCallback -> IO (FunPtr C_ToggleButtonToggledCallback) Source #
onToggleButtonToggled :: (GObject a, MonadIO m) => a -> ToggleButtonToggledCallback -> m SignalHandlerId Source #
wrap_ToggleButtonToggledCallback :: ToggleButtonToggledCallback -> Ptr () -> Ptr () -> IO () Source #