📋
component-sdl2
  • Welcome
  • Setup
  • Getting started with the library
    • Getting started
    • Work with class identifiers
  • Extended work with the library
    • Creating custom components based on the Component class
    • Window event tracking
  • API
    • Supported CSS styles
    • Supported CSS Pseudo-Classes
    • Possible component events to track
    • Possible window events to track
Powered by GitBook
On this page

Was this helpful?

  1. Extended work with the library

Window event tracking

Each window allows you to track events occurring with it (for example, its movement). Each event can have its own callback function. To do this, use the addEventListener method, which is exactly the same as the components and has the following form:

void addEventListener(const string& action, 
                      function<void(window* sender, Event* e) callback>);

Windows can track the following events:

Action

Description

shown

Window has been shown

hidden

Window has been hidden

exposed

Window has been exposed and should be redrawn

moved

Window has been moved to data1, data2

resized

Window has been resized to data1xdata2

minimized

Window has been minimized

maximized

Window has been maximized

restored

Window has been restored to normal size and position

enter

Window has gained mouse focus

leave

Window has lost mouse focus

focus_gained

Window has gained keyboard focus

focus_lost

Window has lost keyboard focus

close

The window manager requests that the window be closed

take_focus

Window is being offered a focus

hit_test

Window had a hit test that wasn't SDL_HITTEST_NORMAL

data1 and data2 are the fields of the window structure of the Event union (for example, access to the data1 field looks like this: e->window.data1).

PreviousCreating custom components based on the Component classNextSupported CSS styles

Last updated 5 years ago

Was this helpful?