WindowEventHandler Derived Type

type, public :: WindowEventHandler

A program's handler of a window's keyboard and mouse events (see the module documentation): extend it and override the procedures wanted (the others do nothing).


Inherited by

type~~windoweventhandler~~InheritedByGraph type~windoweventhandler WindowEventHandler type~windowproxy WindowProxy type~windowproxy->type~windoweventhandler handler

Type-Bound Procedures

procedure, public :: before_draw => handler_before_draw

  • private subroutine handler_before_draw(self, window, t)

    Called each frame just before drawing, the scene at time t and the camera placed (see the module documentation): e.g. to move HUD text next to a moving object, or frames. A view following a frame moved here follows it in this frame's drawing (its transform is taken again after); trajectories' points changed here are drawn from the next frame (change them in before_update).

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window about to draw

    real(kind=wp), intent(in) :: t

    simulation time

procedure, public :: before_update => handler_before_update

  • private subroutine handler_before_update(self, window, t)

    Called each frame with its time t, before the scene is updated for it and the camera placed (see the module documentation): to change the data for time t (trajectories' points, frames' positions), drawn and followed by the views in this frame.

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window about to update

    real(kind=wp), intent(in) :: t

    simulation time

procedure, public :: button_press => handler_button_press

  • private subroutine handler_button_press(self, window, x, y, button)

    A mouse button (MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT) was pressed at (x, y) (see mouse_motion).

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window of the event

    real(kind=wp), intent(in) :: x

    -1 to 1 across the window, y up

    real(kind=wp), intent(in) :: y

    -1 to 1 across the window, y up

    integer, intent(in) :: button

    MOUSE_LEFT, MOUSE_MIDDLE or MOUSE_RIGHT

procedure, public :: button_release => handler_button_release

  • private subroutine handler_button_release(self, window, x, y, button)

    A mouse button was released at (x, y) (see button_press).

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window of the event

    real(kind=wp), intent(in) :: x

    -1 to 1 across the window, y up

    real(kind=wp), intent(in) :: y

    -1 to 1 across the window, y up

    integer, intent(in) :: button

    as button_press's

procedure, public :: handle_drag => handler_handle_drag

  • private subroutine handler_handle_drag(self, window, handle, stage)

    A handle (vkf_handles) was grabbed (DRAG_START), dragged (DRAG_MOVE: it has moved) or released (DRAG_END) with the mouse: e.g. compute again what depends on it (see the module documentation).

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window the handle is dragged in

    class(DragHandle), intent(inout), target :: handle

    the handle (select type for its kind)

    integer, intent(in) :: stage

    DRAG_START, DRAG_MOVE or DRAG_END

procedure, public :: key_press => handler_key_press

  • private subroutine handler_key_press(self, window, key, modifiers, handled)

    A key was pressed: key (a character's code, iachar('v'), or KEY_), with the modifier keys held (MOD_ bits). Set handled (false on entry) to skip the built-in key's action.

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window of the event

    integer, intent(in) :: key

    a character code or KEY_; MOD_ bits

    integer, intent(in) :: modifiers

    a character code or KEY_; MOD_ bits

    logical, intent(inout) :: handled

    (true: skip the built-in key)

procedure, public :: key_release => handler_key_release

  • private subroutine handler_key_release(self, window, key, modifiers)

    A key was released (see key_press).

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window of the event

    integer, intent(in) :: key

    as key_press's

    integer, intent(in) :: modifiers

    as key_press's

procedure, public :: mouse_motion => handler_mouse_motion

  • private subroutine handler_mouse_motion(self, window, x, y, buttons)

    The mouse moved to (x, y) (-1 to 1 across the window, y up), with the buttons held (left, middle, right): moving (none held, OpenFrames' mouse motion) or dragging.

    Arguments

    Type IntentOptional Attributes Name
    class(WindowEventHandler), intent(inout) :: self
    class(WindowProxy), intent(inout) :: window

    the window of the event

    real(kind=wp), intent(in) :: x

    -1 to 1 across the window, y up

    real(kind=wp), intent(in) :: y

    -1 to 1 across the window, y up

    logical, intent(in) :: buttons(3)

    (held: left, middle, right)

Source Code

    type, public :: WindowEventHandler
    contains
        procedure :: key_press => handler_key_press
        procedure :: key_release => handler_key_release
        procedure :: mouse_motion => handler_mouse_motion
        procedure :: button_press => handler_button_press
        procedure :: button_release => handler_button_release
        procedure :: before_update => handler_before_update
        procedure :: before_draw => handler_before_draw
        procedure :: handle_drag => handler_handle_drag
    end type WindowEventHandler