|
Graphics.UI.GIO.Events | Portability | portable | Stability | provisional | Maintainer | ka2_mail@yahoo.com |
|
|
|
|
Contents |
- Event
- Basic events
- Commanding
- Dynamic update
- Reactive
- Activity
- Resizeable
- Scrollable
- Dismissible
- Deadly
- Paint
- Event filters
- Mouse filters
- Keyboard event filters
- Generic event creators
|
|
Description |
Many widgets can respond to events.
There are many basic events: mouse, keyboard, paint, etc. Not
all widgets respond to every event and the events are divided in seperate classes,
like Reactive and Commanding. Events are parametrised by the widget that responds to this event and the type of
their event handler. For example, the
activate event has type: activate :: Form w => Event w (IO ()) This means that all widgets in the Form class can respond to the activate event
with an IO action. The mouse event handler takes a
MouseEvent as an argument and has type: mouse :: Reactive w => Event w (MouseEvent -> IO ()) A specific event handler can be set or read with the on function. For example: do w <- window [title =: "passive"]
set w [on activate =: set w [title =: "active"]]
set w [on deactivate =: set w [title =: "deactive"]] For convenience, the mouse and keyboard events have a serie of event filters,
click, motion, enterKey, charKey, etc. These filters are write-only attributes
but many can be active at the same time. However, all filters will be overwritten again
if the basic event handler mouse or keyboard is set again. For example, the
following program makes sense: window [on mouse =: ..., on click =: ..., on motion =: ...] But in the following program, only the handler for mouse will be called (*): window [on clickRight =: ..., on drag =: ..., on mouse =: ...]
(*) If you want to set the mouse later but want to retain the old event filters,
you can first read the current mouse handler and call that explicitly in the
new event handler (and the same for the keyboard of course). This also the
implementation technique used for the event filters themselves. do w <- window [on click =: ..., on motion =: ...]
prev <- get w (on mouse)
set w [on mouse =: \m -> do{ prev m; ... }]
|
|
Synopsis |
|
|
|
|
Event |
|
data Event w a |
An event for a widget w that expects an event handler of type a. |
|
|
on :: Event w a -> Attr w a |
Get the event handler attribute for a certain event. |
|
off :: Event w a -> Prop w |
|
mapEvent :: (a -> b) -> (a -> b -> a) -> Event w a -> Event w b |
Change the event type. |
|
Basic events |
|
Commanding |
|
class Commanding w |
|
|
command :: (Commanding w) => Event w (IO ()) |
|
Dynamic update |
|
class DynamicUpdate w |
The widgets which are members of DynamicUpdate class has update
event. The update event is raised when the widget can update its state. | | Instances | |
|
|
update :: (DynamicUpdate w) => Event w (IO ()) |
|
Reactive |
|
class Reactive w |
Reactive widgets react to mouse and keyboard events | | Instances | |
|
|
mouse :: (Reactive w) => Event w (MouseEvent -> IO ()) |
|
keyboard :: (Reactive w) => Event w (KeyboardEvent -> IO ()) |
|
contextMenu :: (Reactive w) => Event w (Point -> Modifiers -> IO ()) |
|
Activity |
|
class Activity w |
All widgets which can be activated/deactivated are members of Activity class. | | Instances | |
|
|
activate :: (Activity w) => Event w (IO ()) |
|
deactivate :: (Activity w) => Event w (IO ()) |
|
isactive :: (Activity w) => Attr w Bool |
|
Resizeable |
|
class Resizeable w |
All widgets which the user can dynamicaly resize are members of Resizeable class. | | Instances | |
|
|
resize :: (Resizeable w) => Event w (Size -> IO ()) |
|
resizeable :: (Resizeable w) => Attr w Bool |
Sets/Gets whether the user can resize a widget.
Widgets are user resizable by default. |
|
Scrollable |
|
class Scrollable w |
|
|
scroll :: (Scrollable w) => Event w (Point -> IO ()) |
The event is generated when the user change the current
position of the scollbars |
|
domain :: (Scrollable w) => Attr w Size |
The size of view domain of the widget. If it is larger than
the current view size, scroll bars will appear automatically. |
|
origin :: (Scrollable w) => Attr w Point |
The current position of the scrollbars. The position is given
relatively to the begining of the domain. |
|
Dismissible |
|
class Dismissible w |
The Dismissible widgets can be dissmissed | | Instances | |
|
|
dismissWidget :: (Dismissible w) => w -> IO Bool |
Dismiss a widget |
|
dismiss :: (Dismissible w) => Event w (IO ()) |
The dismiss event is called when the user tries to close the form. |
|
Deadly |
|
class Deadly w |
The Deadly widgets can be destroyed. | | Instances | |
|
|
destroyWidget :: (Deadly w) => w -> IO () |
|
destroy :: (Deadly w) => Event w (IO ()) |
The destroy event is triggered when a widget is destroied. |
|
Paint |
|
class Paint w |
Widgets that can be repainted. | | Instances | |
|
|
paint :: (Paint w) => Event w PaintFunction |
The paint function. |
|
repaint :: (Paint w) => w -> IO () |
Explicitly force a paint event. |
|
paintIn :: (Paint w) => w -> BufferMode -> (Canvas -> IO a) -> IO a |
The paintIn executes the given function with canvas
associated with the given widget. |
|
type PaintFunction = Canvas -> Rect -> [Rect] -> IO () |
A paint function takes a canvas, the update bound rectangle
and the areas that need to be repainted. |
|
Event filters |
|
Mouse filters |
|
motion :: (Reactive w) => Event w (Point -> IO ()) |
|
drag :: (Reactive w) => Event w (Point -> IO ()) |
|
click :: (Reactive w) => Event w (Point -> IO ()) |
|
unclick :: (Reactive w) => Event w (Point -> IO ()) |
|
doubleClick :: (Reactive w) => Event w (Point -> IO ()) |
|
clickRight :: (Reactive w) => Event w (Point -> IO ()) |
|
unclickRight :: (Reactive w) => Event w (Point -> IO ()) |
|
Keyboard event filters |
|
anyKey :: (Reactive w) => Event w (Key -> IO ()) |
|
key :: (Reactive w) => Key -> Event w (IO ()) |
|
charKey :: (Reactive w) => Char -> Event w (IO ()) |
|
enterKey :: (Reactive w) => Event w (IO ()) |
|
tabKey :: (Reactive w) => Event w (IO ()) |
|
escKey :: (Reactive w) => Event w (IO ()) |
|
helpKey :: (Reactive w) => Event w (IO ()) |
|
delKey :: (Reactive w) => Event w (IO ()) |
|
homeKey :: (Reactive w) => Event w (IO ()) |
|
endKey :: (Reactive w) => Event w (IO ()) |
|
pgupKey :: (Reactive w) => Event w (IO ()) |
|
pgdownKey :: (Reactive w) => Event w (IO ()) |
|
downKey :: (Reactive w) => Event w (IO ()) |
|
upKey :: (Reactive w) => Event w (IO ()) |
|
leftKey :: (Reactive w) => Event w (IO ()) |
|
rightKey :: (Reactive w) => Event w (IO ()) |
|
Generic event creators |
|
newEvent :: (w -> IO a) -> (w -> a -> IO ()) -> (w -> IO ()) -> Event w a |
Create a new event from a get and set function. |
|
newStdEvent :: (w -> h) -> (h -> IO a) -> (h -> a -> IO ()) -> (h -> IO ()) -> Event w a |
The newStdEvent function is useful for creation of many standard events |
|
Produced by Haddock version 0.4 |