wx-0.92.3.0: wxHaskell

Copyright(c) Daan Leijen 2003
(c) Shelarcy (shelarcy@gmail.com) 2006
LicensewxWindows
Maintainerwxhaskell-devel@lists.sourceforge.net
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Graphics.UI.WX.Events

Contents

Description

Define event handling. Events are parametrised by the widget that can correspond to a certain event and the type of the event handler. For example, the resize event has type:

Reactive w => Event w (IO ())

This means that all widgets in the Reactive class can respond to resize events (and since Window is an instance of this class, this means that basically all visible widgets are reactive).

An Event w a can be transformed into an attribute of type Attr w a using the on function.

do f <- frame [text := "test"]
   set f [on resize := set f [text := "resizing"]]

For convenience, the mouse and keyboard have a serie of event filters: click, drag, enterKey, charKey, etc. These filters are write-only and do not overwrite any previous mouse or keyboard handler but all stay active at the same time. However, all filters will be overwritten again when mouse or keyboard is set again. For example, the following program makes sense:

set w [on click := ..., on drag := ...]

But in the following program, only the handler for mouse will be called:

set w [on click := ..., on mouse := ...]

If you want to set the mouse later but retain the old event filters, you can first read the current mouse handler and call it in the new handler (and the same for the keyboard, of course). This implementation technique is used to implement event filters themselves and is also very useful when setting an event handler for a closing event:

set w [on closing :~ \previous -> do{ ...; previous }]

Note that you should call propagateEvent (or skipCurrentEvent) whenever you do not process the event yourself in an event handler. This propagates the event to the parent event handlers and give them a chance to handle the event in an appropiate way. This gives another elegant way to install a closing event handler:

set w [on closing := do{ ...; propagateEvent }]

Synopsis

Event

data Event w a Source #

An event for a widget w that expects an event handler of type a.

on :: Event w a -> Attr w a Source #

Transform an event to an attribute.

mapEvent :: (a -> b) -> (a -> b -> a) -> Event w a -> Event w b Source #

Change the event type.

propagateEvent :: IO () #

Pass the event on the next wxWidgets event handler, either on this window or its parent. Always call this method when you do not process the event. (This function just call skipCurrentEvent).

Basic events

Selecting

class Selecting w where Source #

Selecting widgets fire a select event when an item is selected.

Minimal complete definition

select

Methods

select :: Event w (IO ()) Source #

A select event is fired when an item is selected.

select :: Selecting w => Event w (IO ()) Source #

A select event is fired when an item is selected.

Commanding

class Commanding w where Source #

Commanding widgets fire a command event.

Minimal complete definition

command

Methods

command :: Event w (IO ()) Source #

A commanding event, for example a button press.

command :: Commanding w => Event w (IO ()) Source #

A commanding event, for example a button press.

Updating

class Updating w where Source #

Updating widgets fire an update event.

Minimal complete definition

update

Methods

update :: Event w (IO ()) Source #

An update event, for example when the text of a TextCtrl changes. An update event, unlike a command event, is typically a passive state change and doesn't require a response.

update :: Updating w => Event w (IO ()) Source #

An update event, for example when the text of a TextCtrl changes. An update event, unlike a command event, is typically a passive state change and doesn't require a response.

Reactive

class Reactive w where Source #

Reactive widgets are almost all visible widgets on the screen.

Minimal complete definition

mouse, keyboard, closing, idle, resize, focus, activate

Methods

mouse :: Event w (EventMouse -> IO ()) Source #

keyboard :: Event w (EventKey -> IO ()) Source #

closing :: Event w (IO ()) Source #

idle :: Event w (IO Bool) Source #

resize :: Event w (IO ()) Source #

focus :: Event w (Bool -> IO ()) Source #

activate :: Event w (Bool -> IO ()) Source #

closing :: Reactive w => Event w (IO ()) Source #

resize :: Reactive w => Event w (IO ()) Source #

focus :: Reactive w => Event w (Bool -> IO ()) Source #

activate :: Reactive w => Event w (Bool -> IO ()) Source #

class Paint w where Source #

Paint widgets can serve as a canvas. Note: it is illegal to use both a paint and paintRaw event handler at the same widget.

Minimal complete definition

paint, paintRaw, paintGc, repaint

Methods

paint :: Event w (DC () -> Rect -> IO ()) Source #

Paint double buffered to a device context. The context is always cleared before drawing. Takes the current view rectangle (adjusted for scrolling) as an argument.

paintRaw :: Event w (PaintDC () -> Rect -> [Rect] -> IO ()) Source #

Paint directly to the on-screen device context. Takes the current view rectangle and a list of dirty rectangles as arguments.\

paintGc :: Event w (GCDC () -> Rect -> IO ()) Source #

Paint double buffered to a GCDC device context, for anti-aliased drawing. The context is always cleared before drawing. Takes the current view rectangle (adjusted for scrolling) as an argument.

repaint :: w -> IO () Source #

Emit a paint event to the specified widget.

paint :: Paint w => Event w (DC () -> Rect -> IO ()) Source #

Paint double buffered to a device context. The context is always cleared before drawing. Takes the current view rectangle (adjusted for scrolling) as an argument.

paintRaw :: Paint w => Event w (PaintDC () -> Rect -> [Rect] -> IO ()) Source #

Paint directly to the on-screen device context. Takes the current view rectangle and a list of dirty rectangles as arguments.\

paintGc :: Paint w => Event w (GCDC () -> Rect -> IO ()) Source #

Paint double buffered to a GCDC device context, for anti-aliased drawing. The context is always cleared before drawing. Takes the current view rectangle (adjusted for scrolling) as an argument.

repaint :: Paint w => w -> IO () Source #

Emit a paint event to the specified widget.

Event filters

Mouse filters

enter :: Reactive w => Event w (Point -> IO ()) Source #

leave :: Reactive w => Event w (Point -> IO ()) Source #

motion :: Reactive w => Event w (Point -> IO ()) Source #

drag :: Reactive w => Event w (Point -> IO ()) Source #

click :: Reactive w => Event w (Point -> IO ()) Source #

unclick :: Reactive w => Event w (Point -> IO ()) Source #

Keyboard event filters

anyKey :: Reactive w => Event w (Key -> IO ()) Source #

key :: Reactive w => Key -> Event w (IO ()) Source #

charKey :: Reactive w => Char -> Event w (IO ()) Source #

enterKey :: Reactive w => Event w (IO ()) Source #

tabKey :: Reactive w => Event w (IO ()) Source #

escKey :: Reactive w => Event w (IO ()) Source #

helpKey :: Reactive w => Event w (IO ()) Source #

delKey :: Reactive w => Event w (IO ()) Source #

homeKey :: Reactive w => Event w (IO ()) Source #

endKey :: Reactive w => Event w (IO ()) Source #

pgupKey :: Reactive w => Event w (IO ()) Source #

downKey :: Reactive w => Event w (IO ()) Source #

upKey :: Reactive w => Event w (IO ()) Source #

leftKey :: Reactive w => Event w (IO ()) Source #

rightKey :: Reactive w => Event w (IO ()) Source #

rebind :: Event w (IO ()) -> Event w (IO ()) Source #

Types

Modifiers

data Modifiers :: * #

The Modifiers indicate the meta keys that have been pressed (True) or not (False).

Constructors

Modifiers 

Fields

showModifiers :: Modifiers -> String #

Show modifiers, for example for use in menus.

noneDown :: Modifiers #

Construct a Modifiers structure with no meta keys pressed.

justShift :: Modifiers #

Construct a Modifiers structure with just Shift meta key pressed.

justAlt :: Modifiers #

Construct a Modifiers structure with just Alt meta key pressed.

justControl :: Modifiers #

Construct a Modifiers structure with just Ctrl meta key pressed.

justMeta :: Modifiers #

Construct a Modifiers structure with just Meta meta key pressed.

isNoneDown :: Modifiers -> Bool #

Test if no meta key was pressed.

isNoShiftAltControlDown :: Modifiers -> Bool #

Test if no shift, alt, or control key was pressed.

Mouse events

data EventMouse :: * #

Mouse events. The Point gives the logical (unscrolled) position.

Constructors

MouseMotion ~Point ~Modifiers

Mouse was moved over the client area of the window

MouseEnter ~Point ~Modifiers

Mouse enters in the client area of the window

MouseLeave ~Point ~Modifiers

Mouse leaves the client area of the window

MouseLeftDown ~Point ~Modifiers

Mouse left button goes down

MouseLeftUp ~Point ~Modifiers

Mouse left button goes up

MouseLeftDClick ~Point ~Modifiers

Mouse left button double click

MouseLeftDrag ~Point ~Modifiers

Mouse left button drag

MouseRightDown ~Point ~Modifiers

Mouse right button goes down

MouseRightUp ~Point ~Modifiers

Mouse right button goes up

MouseRightDClick ~Point ~Modifiers

Mouse right button double click

MouseRightDrag ~Point ~Modifiers

Mouse right button drag (unsupported on most platforms)

MouseMiddleDown ~Point ~Modifiers

Mouse middle button goes down

MouseMiddleUp ~Point ~Modifiers

Mouse middle button goes up

MouseMiddleDClick ~Point ~Modifiers

Mouse middle button double click

MouseMiddleDrag ~Point ~Modifiers

Mouse middle button drag (unsupported on most platforms)

MouseWheel ~Bool ~Point ~Modifiers

Mouse wheel rotation. (Bool is True for a downward rotation)

showMouse :: EventMouse -> String #

Show an EventMouse in a user friendly way.

mousePos :: EventMouse -> Point #

Extract the position from a MouseEvent.

mouseModifiers :: EventMouse -> Modifiers #

Extract the modifiers from a MouseEvent.

Calender event

AuiNotebook event

data EventAuiNotebook :: * #

AuiNotebook events.

Keyboard events

data EventKey :: * #

A keyboard event contains the key, the modifiers and the focus point.

Constructors

EventKey ~Key ~Modifiers ~Point 

keyKey :: EventKey -> Key #

Extract the key from a keyboard event.

keyModifiers :: EventKey -> Modifiers #

Extract the modifiers from a keyboard event.

keyPos :: EventKey -> Point #

Extract the position from a keyboard event.

showKey :: Key -> String #

Show a key for use in menus for example.

showKeyModifiers :: Key -> Modifiers -> String #

Show a key/modifiers combination, for example for use in menus.

Internal

newEvent :: String -> (w -> IO a) -> (w -> a -> IO ()) -> Event w a Source #

Create a new event from a get and set function.