One event (see vkf_viewer_events): kind, key, key base, modifiers, button, buttons held, x, y (framebuffer pixels from the top left), the render area (x, y, width, height).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(WindowProxy), | intent(inout), | target | :: | self | ||
| integer, | intent(in) | :: | e(12) |
the event (see above) |
subroutine dispatch_event(self, e) class(WindowProxy), intent(inout), target :: self integer, intent(in) :: e(12) !! the event (see above) integer, parameter :: KEY_PRESS = 1, KEY_RELEASE = 2, MOVE = 3, BUTTON_PRESS = 4, BUTTON_RELEASE = 5 integer, parameter :: BUTTON_MASKS(3) = [256, 512, 1024] ! (VSG's BUTTON_MASK_1/2/3) integer :: key real(wp) :: x, y logical :: handled key = e(2) if (key == 0) key = e(3) ! (no modified key given) x = 0.0_wp y = 0.0_wp if (e(11) > 0) x = 2.0_wp * real(e(7) - e(9), wp) / real(e(11), wp) - 1.0_wp if (e(12) > 0) y = 1.0_wp - 2.0_wp * real(e(8) - e(10), wp) / real(e(12), wp) select case (e(1)) case (KEY_PRESS) handled = .false. if (associated(self%handler)) call self%handler%key_press(self, key, e(4), handled) if (.not. handled .and. self%default_keys_ .and. self%is_open()) call default_key(self, key, e(4)) case (KEY_RELEASE) if (associated(self%handler)) call self%handler%key_release(self, key, e(4)) case (MOVE) if (e(2) == 1) then ! (grabbed: a handle dragged) call drag_handle(self, x, y) return end if if (all(iand(e(6), BUTTON_MASKS) == 0)) call hover_handle(self, x, y) ! (no button held) if (associated(self%handler)) call self%handler%mouse_motion(self, x, y, iand(e(6), BUTTON_MASKS) /= 0) case (BUTTON_PRESS) self%flight%active = .false. ! (the mouse takes the camera) if (e(2) == 1) then call grab_handle(self, x, y) return end if if (associated(self%handler)) call self%handler%button_press(self, x, y, e(5)) case (BUTTON_RELEASE) if (e(2) == 1) then call release_handle(self, x, y) return end if if (associated(self%handler)) call self%handler%button_release(self, x, y, e(5)) end select end subroutine dispatch_event