gtk3-0.15.10: Binding to the Gtk+ 3 graphical user interface library

Maintainer | gtk2hs-users@lists.sourceforge.net
Stability | provisional
Portability | portable (depends on GHC)
Safe Haskell | None
Language | Haskell98

Graphics.UI.Gtk.Entry.Editable

Contents

- Detail
- Class Hierarchy
- Types
- Methods
- Attributes
- Signals
- Deprecated

Description

Interface for text-editing widgets

Synopsis

- data Editable
- class GObjectClass o => EditableClass o
- castToEditable :: GObjectClass obj => obj -> Editable
- gTypeEditable :: GType
- toEditable :: EditableClass o => o -> Editable
- editableSelectRegion :: EditableClass self => self -> Int -> Int -> IO ()
- editableGetSelectionBounds :: EditableClass self => self -> IO (Int, Int)
- editableInsertText :: (EditableClass self, GlibString string) => self -> string -> Int -> IO Int
- editableDeleteText :: EditableClass self => self -> Int -> Int -> IO ()
- editableGetChars :: (EditableClass self, GlibString string) => self -> Int -> Int -> IO string
- editableCutClipboard :: EditableClass self => self -> IO ()
- editableCopyClipboard :: EditableClass self => self -> IO ()
- editablePasteClipboard :: EditableClass self => self -> IO ()
- editableDeleteSelection :: EditableClass self => self -> IO ()
- editableSetEditable :: EditableClass self => self -> Bool -> IO ()
- editableGetEditable :: EditableClass self => self -> IO Bool
- editableSetPosition :: EditableClass self => self -> Int -> IO ()
- editableGetPosition :: EditableClass self => self -> IO Int
- editablePosition :: EditableClass self => Attr self Int
- editableEditable :: EditableClass self => Attr self Bool
- editableChanged :: EditableClass ec => Signal ec (IO ())
- deleteText :: EditableClass self => Signal self (Int -> Int -> IO ())
- insertText :: (EditableClass self, GlibString string) => Signal self (string -> Int -> IO Int)
- stopDeleteText :: EditableClass self => ConnectId self -> IO ()
- stopInsertText :: EditableClass self => ConnectId self -> IO ()

# Detail

The `Editable` interface is an interface which should be implemented by text editing widgets, such as `Entry`. It contains functions for generically manipulating an editable widget, a large number of action signals used for key bindings, and several signals that an application can connect to to modify the behavior of a widget.

# Class Hierarchy

    | GInterface
    | +----Editable

# Types

data Editable Source #

#### Instances

Instances details

Eq Editable Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods (==) :: Editable -> Editable -> Bool Source # (/=) :: Editable -> Editable -> Bool Source #
Ord Editable Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods compare :: Editable -> Editable -> Ordering Source # (<) :: Editable -> Editable -> Bool Source # (<=) :: Editable -> Editable -> Bool Source # (>) :: Editable -> Editable -> Bool Source # (>=) :: Editable -> Editable -> Bool Source # max :: Editable -> Editable -> Editable Source # min :: Editable -> Editable -> Editable Source #
GObjectClass Editable Source # |
Instance details Defined in Graphics.UI.Gtk.Types Methods toGObject :: Editable -> GObject Source # unsafeCastGObject :: GObject -> Editable Source #
EditableClass Editable Source # |
Instance details Defined in Graphics.UI.Gtk.Types

class GObjectClass o => EditableClass o Source #

#### Instances

Instances details

EditableClass Editable Source # |
Instance details Defined in Graphics.UI.Gtk.Types
EditableClass Entry Source # |
Instance details Defined in Graphics.UI.Gtk.Entry.Entry
EditableClass SpinButton Source # |
Instance details Defined in Graphics.UI.Gtk.Entry.SpinButton

castToEditable :: GObjectClass obj => obj -> Editable Source #

gTypeEditable :: GType Source #

toEditable :: EditableClass o => o -> Editable Source #

# Methods

editableSelectRegion Source #

Arguments

:: EditableClass self |
=> self |
-> Int | `start` - the starting position.
-> Int | `end` - the end position.
-> IO () |

Selects a region of text. The characters that are selected are those characters at positions from `startPos` up to, but not including `endPos`. If `endPos` is negative, then the the characters selected will be those characters from `startPos` to the end of the text.

Calling this function with `start`=1 and `end`=4 it will mark "ask" in the string "Haskell".

editableGetSelectionBounds Source #

Arguments

:: EditableClass self |
=> self |
-> IO (Int, Int) | `(start, end)` - the starting and end positions. This pair is not ordered. The `end` index represents the position of the cursor. The `start` index is the other end of the selection. If both numbers are equal there is in fact no selection.

Gets the current selection bounds, if there is a selection.

editableInsertText Source #

Arguments

:: (EditableClass self, GlibString string) |
=> self |
-> string | `newText` - the text to insert.
-> Int | `position` - the position at which to insert the text.
-> IO Int | returns the position after the newly inserted text.

Inserts text at a given position.

editableDeleteText Source #

Arguments

:: EditableClass self |
=> self |
-> Int | `startPos` - the starting position.
-> Int | `endPos` - the end position.
-> IO () |

Deletes a sequence of characters. The characters that are deleted are those characters at positions from `startPos` up to, but not including `endPos`. If `endPos` is negative, then the the characters deleted will be those characters from `startPos` to the end of the text.

editableGetChars Source #

Arguments

:: (EditableClass self, GlibString string) |
=> self |
-> Int | `startPos` - the starting position.
-> Int | `endPos` - the end position.
-> IO string | returns the characters in the indicated region.

Retrieves a sequence of characters. The characters that are retrieved are those characters at positions from `startPos` up to, but not including `endPos`. If `endPos` is negative, then the the characters retrieved will be those characters from `startPos` to the end of the text.

editableCutClipboard :: EditableClass self => self -> IO () Source #

Causes the characters in the current selection to be copied to the clipboard and then deleted from the widget.

editableCopyClipboard :: EditableClass self => self -> IO () Source #

Causes the characters in the current selection to be copied to the clipboard.

editablePasteClipboard :: EditableClass self => self -> IO () Source #

Causes the contents of the clipboard to be pasted into the given widget at the current cursor position.

editableDeleteSelection :: EditableClass self => self -> IO () Source #

Deletes the current contents of the widgets selection and disclaims the selection.

editableSetEditable Source #

Arguments

:: EditableClass self |
=> self |
-> Bool | `isEditable` - `True` if the user is allowed to edit the text in the widget.
-> IO () |

Determines if the user can edit the text in the editable widget or not.

editableGetEditable :: EditableClass self => self -> IO Bool Source #

Retrieves whether the text is editable. See `editableSetEditable`.

editableSetPosition Source #

Arguments

:: EditableClass self |
=> self |
-> Int | `position` - the position of the cursor. The cursor is displayed before the character with the given (base 0) index in the widget. The value must be less than or equal to the number of characters in the widget. A value of -1 indicates that the position should be set after the last character in the entry.
-> IO () |

Sets the cursor position.

editableGetPosition Source #

Arguments

:: EditableClass self |
=> self |
-> IO Int | returns the position of the cursor. The cursor is displayed before the character with the given (base 0) index in the widget. The value will be less than or equal to the number of characters in the widget. Note that this position is in characters, not in bytes.

Retrieves the current cursor position.

# Attributes

editablePosition :: EditableClass self => Attr self Int Source #

'position' property. See `editableGetPosition` and `editableSetPosition`

editableEditable :: EditableClass self => Attr self Bool Source #

'editable' property. See `editableGetEditable` and `editableSetEditable`

# Signals

editableChanged :: EditableClass ec => Signal ec (IO ()) Source #

The `editableChanged` signal is emitted at the end of a single user-visible operation on the contents of the `Editable`.

- For instance, a paste operation that replaces the contents of the selection will cause only one signal emission (even though it is implemented by first deleting the selection, then inserting the new content, and may cause multiple `insertText` signals to be emitted).

deleteText Source #

Arguments

:: EditableClass self |

=> Signal self (Int -> Int -> IO ())

    (startPos endPos -> ...)

Emitted when a piece of text is deleted from the `Editable` widget.

- See `insertText` for information on how to use this signal.

insertText :: (EditableClass self, GlibString string) => Signal self (string -> Int -> IO Int) Source #

Emitted when a piece of text is inserted into the `Editable` widget.

- The connected signal receives the text that is inserted, together with the position in the entry widget. The return value should be the position in the entry widget that lies past the recently inserted text (i.e. you should return the given position plus the length of the string).
- To modify the text that the user inserts, you need to connect to this signal, modify the text the way you want and then call `editableInsertText`. To avoid that this signal handler is called recursively, you need to temporarily block it using `signalBlock`. After the default signal handler has inserted your modified text, it is important that you prevent the default handler from being executed again when this signal handler returns. To stop the current signal, use `stopInsertText`. The following code is an example of how to turn all input into uppercase:

    idRef <- newIORef undefined
    id <- entry `on` insertText $ \str pos -> do
    id <- readIORef idRef
    signalBlock id
    pos' <- editableInsertText entry (map toUpper str) pos
    signalUnblock id
    stopInsertText id
    return pos'
    writeIORef idRef id

Note that binding `insertText` using `after` is not very useful, except to track editing actions.

stopDeleteText :: EditableClass self => ConnectId self -> IO () Source #

Stop the current signal that deletes text.

stopInsertText :: EditableClass self => ConnectId self -> IO () Source #

Stop the current signal that inserts text.

# Deprecated