Magnum::Platform::Sdl2Application class

SDL2 application.

Application using Simple DirectMedia Layer toolkit. Supports keyboard and mouse handling.

This application library is in theory available for all platforms for which SDL2 is ported (thus also Emscripten, see respective sections in Corrade's and Magnum's building documentation). It depends on the SDL2 library (Emscripten has it built in) and is built if WITH_SDL2APPLICATION is enabled in CMake.

Bootstrap application

Fully contained base application using Sdl2Application along with CMake setup is available in base branch of Magnum Bootstrap repository, download it as tar.gz or zip file. After extracting the downloaded archive you can build and run the application with these four commands:

mkdir build && cd build
cmake ..
cmake --build .
./src/MyApplication # or ./src/Debug/MyApplication

See Usage with CMake for more information.

Bootstrap application for Emscripten

Fully contained base application using Sdl2Application for both desktop and Emscripten build along with full HTML markup and CMake setup is available in base-emscripten branch of Magnum Bootstrap repository, download it as tar.gz or zip file. After extracting the downloaded archive, you can do the desktop build in the same way as above. For the Emscripten build you also need to put the contents of toolchains repository from https://github.com/mosra/toolchains in toolchains/ subdirectory. There are two toolchain files. The generic/Emscripten.cmake is for the classical (asm.js) build, the generic/Emscripten-wasm.cmake is for WebAssembly build. Don't forget to adapt EMSCRIPTEN_PREFIX variable in toolchains/generic/Emscripten*.cmake to path where Emscripten is installed; you can also pass it explicitly on command-line using -DEMSCRIPTEN_PREFIX. Default is /usr/emscripten.

Then create build directory and run cmake and build/install commands in it. Set CMAKE_PREFIX_PATH to where you have all the dependencies installed, set CMAKE_INSTALL_PREFIX to have the files installed in proper location (a webserver, e.g. /srv/http/emscripten).

mkdir build-emscripten && cd build-emscripten
cmake .. \
    -DCMAKE_TOOLCHAIN_FILE="../toolchains/generic/Emscripten.cmake" \
    -DCMAKE_PREFIX_PATH=/usr/lib/emscripten/system \
    -DCMAKE_INSTALL_PREFIX=/srv/http/emscripten
cmake --build .
cmake --build . --target install

You can then open MyApplication.html in your browser (through a webserver, e.g. http://localhost/emscripten/MyApplication.html).

Detailed information about deployment for Emscripten and all needed boilerplate together with a troubleshooting guide is available in JavaScript, HTML5 and WebGL.

Bootstrap application for iOS

Fully contained base application using Sdl2Application for both desktop and iOS build along with pre-filled *.plist is available in base-ios branch of Magnum Bootstrap repository, download it as tar.gz or zip file. After extracting the downloaded archive, you can do the desktop build in the same way as above. For the iOS build you also need to put the contents of toolchains repository from https://github.com/mosra/toolchains in toolchains/ subdirectory.

Then create build directory and run cmake to generate the Xcode project. Set CMAKE_OSX_ROOT to SDK you want to target and enable all desired architectures in CMAKE_OSX_ARCHITECTURES. Set CMAKE_PREFIX_PATH to the directory where you have all the dependencies.

mkdir build-ios && cd build-ios
cmake .. \
    -DCMAKE_TOOLCHAIN_FILE=../toolchains/generic/iOS.cmake \
    -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
    -DCMAKE_OSX_ARCHITECTURES="arm64;armv7;armv7s" \
    -DCMAKE_PREFIX_PATH=~/ios-libs \
    -G Xcode

You can then open the generated project file in Xcode and build/deploy it from there.

Bootstrap application for Windows RT

Fully contained base application using Sdl2Application for both desktop and Windows Phone / Windows Store build along with all required plumbing is available in base-winrt branch of Magnum Bootstrap repository, download it as zip file. After extracting the downloaded archive, you can do the desktop build in the same way as above.

For the Windows RT build you need to provide your own *.pfx certificate file and pass it to CMake in a SIGNING_CERTIFICATE variable. The bootstrap application assumes that SDL2 and ANGLE is built as DLL and both Corrade and Magnum are built statically. Assuming the native Corrade installation is in C:/Sys and all WinRT dependencies are in C:/Sys-winrt, the build can be done similarly to the following:

mkdir build-winrt && cd build-winrt
cmake .. ^
    -DCORRADE_RC_EXECUTABLE="C:/Sys/bin/corrade-rc.exe" ^
    -DCMAKE_PREFIX_PATH="C:/Sys-winrt" ^
    -DCMAKE_SYSTEM_NAME=WindowsStore ^
    -DCMAKE_SYSTEM_VERSION=8.1 ^
    -G "Visual Studio 14 2015" ^
    -DSIGNING_CERTIFICATE=<path-to-your-pfx-file>
cmake --build .

Change WindowsStore to WindowsPhone if you want to build for Windows Phone instead. The build-winrt/src/AppPackages directory will then contain the final package along with a PowerShell script for easy local installation.

General usage

In order to use this library from CMake, you need to copy FindSDL2.cmake from the modules/ directory in Magnum source to the modules/ dir in your project (so it is able to find the SDL2 library). In case of Emscripten you need also FindOpenGLES2.cmake / FindOpenGLES3.cmake. Request the Sdl2Application component of the Magnum package and link to the Magnum::Sdl2Application target:

find_package(Magnum REQUIRED Sdl2Application)

# ...
target_link_libraries(your-app Magnum::Sdl2Application)

If no other application is requested, you can also use the generic Magnum::Application alias to simplify porting. Again, see Downloading and building and Usage with CMake for more information.

In C++ code you need to implement at least drawEvent() to be able to draw on the screen. The subclass can be then used directly in main() — see convenience macro MAGNUM_SDL2APPLICATION_MAIN(). See Platform support for more information.

class MyApplication: public Platform::Sdl2Application {
    // implement required methods...
};
MAGNUM_SDL2APPLICATION_MAIN(MyApplication)

If no other application header is included, this class is also aliased to Platform::Application and the macro is aliased to MAGNUM_APPLICATION_MAIN() to simplify porting.

Linux specifics

SDL by default attempts to disable compositing, which may cause ugly flickering for non-fullscreen apps (KWin, among others, is known to respect this setting). When using SDL >= 2.0.8, Sdl2Application turns this behavior off, keeping the compositor running to avoid the flicker. You can turn this behavior back on by enabling the corresponding SDL hint through an environment variable:

SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR=1 ./your-app

If you're running an older version of SDL, you can disallow apps from bypassing the compositor in system-wide KWin settings.

iOS specifics

Leaving a default (zero) window size in Configuration will cause the app to autodetect it based on the actual device screen size. This also depends on DPI awareness, see below for details.

As noted in the iOS platform guide, a lot of options needs to be set via a *.plist file. Some options can be configured from runtime when creating the SDL2 application window, see documentation of a particular value for details:

Emscripten specifics

Leaving a default (zero) window size in Configuration will cause the app to use a window size that corresponds to CSS pixel size of the <canvas> element. The size is then multiplied by DPI scaling value, see DPI awareness below for details.

If you enable Configuration::WindowFlag::Resizable, the canvas will be resized when size of the canvas changes and you get viewportEvent(). If the flag is not enabled, no canvas resizing is performed.

DPI awareness

On displays that match the platform default DPI (96 or 72), Configuration::setSize() will create the window in exactly the requested size and the framebuffer pixels will match display pixels 1:1. On displays that have different DPI, there are three possible scenarios, listed below. It's possible to fine tune the behavior either using extra parameters passed to Configuration::setSize() or via the --magnum-dpi-scaling command-line option (or the equivalent $MAGNUM_DPI_SCALING environment variable).

  • Framebuffer DPI scaling. The window is created with exactly the requested size and all event coordinates are reported also relative to that size. However, the window backing framebuffer has a different size. This is only supported on macOS and iOS. See HiDPI (Retina) support for details how to enable it. Equivalent to passing Configuration::DpiScalingPolicy::Framebuffer to Configuration::setSize() or framebuffer via command line / environment.
  • Virtual DPI scaling. Scales the window based on DPI scaling setting in the system. For example if a 800x600 window is requested and DPI scaling is set to 200%, the resulting window will have 1600x1200 pixels. The backing framebuffer will have the same size. This is supported on Linux and Windows. Equivalent to passing Configuration::DpiScalingPolicy::Virtual to Configuration::setSize() or virtual on command line.
  • Physical DPI scaling. Takes the requested window size as a physical size that a window would have on platform's default DPI and scales it to have the same physical size on given display physical DPI. So, for example on a display with 240 DPI the window size will be 2000x1500 in pixels, but it will be 21 centimeters wide, the same as a 800x600 window would be on a 96 DPI display. On platforms that don't have a concept of a window (such as mobile platforms or Emscripten), it causes the framebuffer to match display pixels 1:1 without any scaling. This is supported on Linux, Windows, all mobile platforms except iOS and Emscripten. Equivalent to passing Configuration::DpiScalingPolicy::Physical to Configuration::setSize() or physical via command line / environment.

Besides the above, it's possible to supply a custom DPI scaling value to Configuration::setSize() or the --magnum-dpi-scaling command-line option (or environment variable). Using --magnum-dpi-scaling <number> will make the scaling same in both directions, with --magnum-dpi-scaling "<horizontal> <vertical>" the scaling will be different in each direction. On desktop systems custom DPI scaling value will affect physical window size (with the content being scaled), on mobile and web it will affect sharpness of the contents.

The default is depending on the platform:

If your application is saving and restoring window size, it's advisable to take dpiScaling() into account:

  • Either divide the window size by the DPI scaling value and use that to restore the window next time — but note this might accumulate slight differences in window sizes over time, especially if fractional scaling is involved.
  • Or save the scaled size and use Configuration::setSize(const Vector2i&, const Vector2&) with 1.0f as custom DPI scaling next time — but this doesn't properly handle cases where the window is opened on a display with different DPI.

Public types

struct Arguments
Application arguments.
class Configuration
Configuration.
class GLConfiguration
OpenGL context configuration.
class InputEvent
Base for input events.
class KeyEvent
Key event.
class MouseEvent
Mouse event.
class MouseMoveEvent
Mouse move event.
class MouseScrollEvent
Mouse scroll event.
class MultiGestureEvent
Multi gesture event.
class TextEditingEvent
Text editing event.
class TextInputEvent
Text input event.
class ViewportEvent
Viewport event.

Constructors, destructors, conversion operators

Sdl2Application(const Arguments& arguments, const Configuration& configuration, const GLConfiguration& glConfiguration) explicit
Construct with given configuration for OpenGL context.
Sdl2Application(const Arguments& arguments, const Configuration& configuration) explicit
Construct with given configuration.
Sdl2Application(const Arguments& arguments) explicit
Construct with default configuration.
Sdl2Application(const Arguments& arguments, NoCreateT) explicit
Construct without creating a window.
Sdl2Application(const Arguments& arguments, std::nullptr_t) deprecated explicit
Construct without creating a window.
Sdl2Application(const Sdl2Application&) deleted
Copying is not allowed.
Sdl2Application(Sdl2Application&&) deleted
Moving is not allowed.

Public functions

auto operator=(const Sdl2Application&) -> Sdl2Application& deleted
Copying is not allowed.
auto operator=(Sdl2Application&&) -> Sdl2Application& deleted
Moving is not allowed.
auto exec() -> int
Execute main loop.
void exit()
Exit application main loop.
void mainLoopIteration()
Run one iteration of application main loop.
auto window() -> SDL_Window*
Underlying window handle.

Protected functions

void create(const Configuration& configuration, const GLConfiguration& glConfiguration)
Create a window with given configuration for OpenGL context.
void create(const Configuration& configuration)
Create a window with given configuration.
void create()
Create a window with default configuration and OpenGL context.
void createContext(const Configuration& configuration) deprecated
Create a window with given configuration for OpenGL context.
void createContext() deprecated
Create a window with default configuration and OpenGL context.
auto tryCreate(const Configuration& configuration, const GLConfiguration& glConfiguration) -> bool
Try to create context with given configuration for OpenGL context.
auto tryCreate(const Configuration& configuration) -> bool
Try to create context with given configuration.
auto tryCreateContext(const Configuration& configuration) -> bool deprecated
Try to create context with given configuration for OpenGL context.

Screen handling

auto windowSize() const -> Vector2i
Window size.
auto framebufferSize() const -> Vector2i
Framebuffer size.
auto dpiScaling() const -> Vector2
DPI scaling.
auto dpiScaling(const Configuration& configuration) const -> Vector2
DPI scaling for given configuration.
void setContainerCssClass(const std::string& cssClass)
Set container CSS class.
void swapBuffers() protected
Swap buffers.
auto swapInterval() const -> Int protected
Swap interval.
auto setSwapInterval(Int interval) -> bool protected
Set swap interval.
void setMinimalLoopPeriod(UnsignedInt milliseconds) protected
Set minimal loop period.
void redraw() protected
Redraw immediately.
void tickEvent() protected virtual
Tick event.
void viewportEvent(ViewportEvent& event) protected virtual
Viewport event.
void viewportEvent(const Vector2i& size) deprecated protected virtual
Viewport event.
void drawEvent() protected pure virtual
Draw event.

Keyboard handling

void keyPressEvent(KeyEvent& event) protected virtual
Key press event.
void keyReleaseEvent(KeyEvent& event) protected virtual
Key release event.

Mouse handling

auto isMouseLocked() const -> bool
Whether mouse is locked.
void setMouseLocked(bool enabled)
Enable or disable mouse locking.
void mousePressEvent(MouseEvent& event) protected virtual
Mouse press event.
void mouseReleaseEvent(MouseEvent& event) protected virtual
Mouse release event.
void mouseMoveEvent(MouseMoveEvent& event) protected virtual
Mouse move event.
void mouseScrollEvent(MouseScrollEvent& event) protected virtual
Mouse scroll event.

Touch gesture handling

void multiGestureEvent(MultiGestureEvent& event) protected virtual
Multi gesture event.

Text input handling

auto isTextInputActive() -> bool
Whether text input is active.
void startTextInput()
Start text input.
void stopTextInput()
Stop text input.
void setTextInputRect(const Range2Di& rect)
Set text input rectangle.
void textInputEvent(TextInputEvent& event) protected virtual
Text input event.
void textEditingEvent(TextEditingEvent& event) protected virtual
Text editing event.

Function documentation

Magnum::Platform::Sdl2Application::Sdl2Application(const Arguments& arguments, const Configuration& configuration, const GLConfiguration& glConfiguration) explicit

Construct with given configuration for OpenGL context.

Parameters
arguments Application arguments
configuration Application configuration
glConfiguration OpenGL context configuration

Creates application with default or user-specified configuration. See Configuration for more information. The program exits if the context cannot be created, see tryCreate() for an alternative.

Magnum::Platform::Sdl2Application::Sdl2Application(const Arguments& arguments, const Configuration& configuration) explicit

Construct with given configuration.

If Configuration::WindowFlag::Contextless is present or Magnum was not built with MAGNUM_TARGET_GL, this creates a window without any GPU context attached, leaving that part on the user.

If none of the flags is present and Magnum was built with MAGNUM_TARGET_GL, this is equivalent to calling Sdl2Application(const Arguments&, const Configuration&, const GLConfiguration&) with default-constructed GLConfiguration.

See also Enabling or disabling features for more information.

Magnum::Platform::Sdl2Application::Sdl2Application(const Arguments& arguments) explicit

Construct with default configuration.

Equivalent to calling Sdl2Application(const Arguments&, const Configuration&) with default-constructed Configuration.

Magnum::Platform::Sdl2Application::Sdl2Application(const Arguments& arguments, NoCreateT) explicit

Construct without creating a window.

Parameters
arguments Application arguments

Unlike above, the window is not created and must be created later with create() or tryCreate().

Magnum::Platform::Sdl2Application::Sdl2Application(const Arguments& arguments, std::nullptr_t) explicit

Construct without creating a window.

int Magnum::Platform::Sdl2Application::exec()

Execute main loop.

Returns Value for returning from main()

Calls mainLoopIteration() in a loop until exit() is called. See MAGNUM_SDL2APPLICATION_MAIN() for usage information.

void Magnum::Platform::Sdl2Application::exit()

Exit application main loop.

Stops main loop started by exec().

void Magnum::Platform::Sdl2Application::mainLoopIteration()

Run one iteration of application main loop.

Called internally from exec(). If you want to have better control over how the main loop behaves, you can call this function yourself from your own main() function instead of it being called automatically from exec() / MAGNUM_SDL2APPLICATION_MAIN().

SDL_Window* Magnum::Platform::Sdl2Application::window()

Underlying window handle.

Use in case you need to call SDL functionality directly.

void Magnum::Platform::Sdl2Application::create(const Configuration& configuration, const GLConfiguration& glConfiguration) protected

Create a window with given configuration for OpenGL context.

Parameters
configuration Application configuration
glConfiguration OpenGL context configuration

Must be called only if the context wasn't created by the constructor itself, i.e. when passing NoCreate to it. Error message is printed and the program exits if the context cannot be created, see tryCreate() for an alternative.

On desktop GL, if version is not specified in glConfiguration, the application first tries to create core context (OpenGL 3.2+ on macOS, OpenGL 3.1+ elsewhere) and if that fails, falls back to compatibility OpenGL 2.1 context.

void Magnum::Platform::Sdl2Application::create(const Configuration& configuration) protected

Create a window with given configuration.

If Configuration::WindowFlag::Contextless is present or Magnum was not built with MAGNUM_TARGET_GL, this creates a window without any GPU context attached, leaving that part on the user.

If none of the flags is present and Magnum was built with MAGNUM_TARGET_GL, this is equivalent to calling create(const Configuration&, const GLConfiguration&) with default-constructed GLConfiguration.

See also Enabling or disabling features for more information.

void Magnum::Platform::Sdl2Application::create() protected

Create a window with default configuration and OpenGL context.

Equivalent to calling create(const Configuration&) with default-constructed Configuration.

void Magnum::Platform::Sdl2Application::createContext(const Configuration& configuration) protected

Create a window with given configuration for OpenGL context.

void Magnum::Platform::Sdl2Application::createContext() protected

Create a window with default configuration and OpenGL context.

bool Magnum::Platform::Sdl2Application::tryCreate(const Configuration& configuration, const GLConfiguration& glConfiguration) protected

Try to create context with given configuration for OpenGL context.

Unlike create(const Configuration&, const GLConfiguration&) returns false if the context cannot be created, true otherwise.

bool Magnum::Platform::Sdl2Application::tryCreate(const Configuration& configuration) protected

Try to create context with given configuration.

Unlike create(const Configuration&) returns false if the context cannot be created, true otherwise.

bool Magnum::Platform::Sdl2Application::tryCreateContext(const Configuration& configuration) protected

Try to create context with given configuration for OpenGL context.

Vector2i Magnum::Platform::Sdl2Application::windowSize() const

Window size.

Window size to which all input event coordinates can be related. Note that, especially on HiDPI systems, it may be different from framebufferSize(). Expects that a window is already created. See DPI awareness for more information.

Vector2i Magnum::Platform::Sdl2Application::framebufferSize() const

Framebuffer size.

Size of the default framebuffer. Note that, especially on HiDPI systems, it may be different from windowSize(). Expects that a window is already created. See DPI awareness for more information.

Vector2 Magnum::Platform::Sdl2Application::dpiScaling() const

DPI scaling.

How the content should be scaled relative to system defaults for given windowSize(). If a window is not created yet, returns zero vector, use dpiScaling(const Configuration&) const for calculating a value independently. See DPI awareness for more information.

Vector2 Magnum::Platform::Sdl2Application::dpiScaling(const Configuration& configuration) const

DPI scaling for given configuration.

Calculates DPI scaling that would be used when creating a window with given configuration. Takes into account DPI scaling policy and custom scaling specified on the command-line. See DPI awareness for more information.

void Magnum::Platform::Sdl2Application::setContainerCssClass(const std::string& cssClass)

Set container CSS class.

Assigns given CSS class to the <div class="container">. Useful for example to change aspect ratio of the view or stretch it to cover the full page. See Modifying page style, canvas size and aspect ratio for more information about possible values. Note that this replaces any existing class, to set multiple classes separate them with whitespace.

void Magnum::Platform::Sdl2Application::swapBuffers() protected

Swap buffers.

Paints currently rendered framebuffer on screen.

bool Magnum::Platform::Sdl2Application::setSwapInterval(Int interval) protected

Set swap interval.

Set 0 for no VSync, 1 for enabled VSync. Some platforms support -1 for late swap tearing. Prints error message and returns false if swap interval cannot be set, true otherwise. Default is driver-dependent, you can query the value with swapInterval().

void Magnum::Platform::Sdl2Application::setMinimalLoopPeriod(UnsignedInt milliseconds) protected

Set minimal loop period.

This setting reduces the main loop frequency in case VSync is not/cannot be enabled or no drawing is done. Default is 0 (i.e. looping at maximum frequency).

void Magnum::Platform::Sdl2Application::redraw() protected

Redraw immediately.

Marks the window for redrawing, resulting in call to drawEvent() in the next iteration. You can call it from drawEvent() itself to redraw immediately without waiting for user input.

void Magnum::Platform::Sdl2Application::tickEvent() virtual protected

Tick event.

If implemented, this function is called periodically after processing all input events and before draw event even though there might be no input events and redraw is not requested. Useful e.g. for asynchronous task polling. Use setMinimalLoopPeriod()/ setSwapInterval() to control main loop frequency.

void Magnum::Platform::Sdl2Application::viewportEvent(ViewportEvent& event) virtual protected

Viewport event.

Called when window size changes. The default implementation does nothing. If you want to respond to size changes, you should pass the new framebuffer size to GL::DefaultFramebuffer::setViewport() (if using OpenGL) and possibly elsewhere (to SceneGraph::Camera::setViewport(), other framebuffers...) and the new window size and DPI scaling to APIs that respond to user events or scale UI elements.

Note that this function might not get called at all if the window size doesn't change. You should configure the initial state of your cameras, framebuffers etc. in application constructor rather than relying on this function to be called. Size of the window can be retrieved using windowSize(), size of the backing framebuffer via framebufferSize() and DPI scaling using dpiScaling(). See DPI awareness for detailed info about these values.

void Magnum::Platform::Sdl2Application::viewportEvent(const Vector2i& size) virtual protected

Viewport event.

void Magnum::Platform::Sdl2Application::drawEvent() pure virtual protected

Draw event.

Called when the screen is redrawn. You should clean the framebuffer using GL::DefaultFramebuffer::clear() (if using OpenGL) and then add your own drawing functions. After drawing is finished, call swapBuffers(). If you want to draw immediately again, call also redraw().

void Magnum::Platform::Sdl2Application::keyPressEvent(KeyEvent& event) virtual protected

Key press event.

Called when an key is pressed. Default implementation does nothing.

void Magnum::Platform::Sdl2Application::keyReleaseEvent(KeyEvent& event) virtual protected

Key release event.

Called when an key is released. Default implementation does nothing.

void Magnum::Platform::Sdl2Application::setMouseLocked(bool enabled)

Enable or disable mouse locking.

When mouse is locked, the cursor is hidden and only MouseMoveEvent::relativePosition() is changing, absolute position stays the same.

void Magnum::Platform::Sdl2Application::mousePressEvent(MouseEvent& event) virtual protected

Mouse press event.

Called when mouse button is pressed. Default implementation does nothing.

void Magnum::Platform::Sdl2Application::mouseReleaseEvent(MouseEvent& event) virtual protected

Mouse release event.

Called when mouse button is released. Default implementation does nothing.

void Magnum::Platform::Sdl2Application::mouseMoveEvent(MouseMoveEvent& event) virtual protected

Mouse move event.

Called when mouse is moved. Default implementation does nothing.

void Magnum::Platform::Sdl2Application::mouseScrollEvent(MouseScrollEvent& event) virtual protected

Mouse scroll event.

Called when a scrolling device is used (mouse wheel or scrolling area on a touchpad). Default implementation does nothing.

void Magnum::Platform::Sdl2Application::multiGestureEvent(MultiGestureEvent& event) virtual protected

Multi gesture event.

Called when the user performs a gesture using multiple fingers. Default implementation does nothing.

bool Magnum::Platform::Sdl2Application::isTextInputActive()

Whether text input is active.

If text input is active, text input events go to textInputEvent() and textEditingEvent().

void Magnum::Platform::Sdl2Application::startTextInput()

Start text input.

Starts text input that will go to textInputEvent() and textEditingEvent().

void Magnum::Platform::Sdl2Application::stopTextInput()

Stop text input.

Stops text input that went to textInputEvent() and textEditingEvent().

void Magnum::Platform::Sdl2Application::setTextInputRect(const Range2Di& rect)

Set text input rectangle.

The rect defines an area where the text is being displayed, for example to hint the system where to place on-screen keyboard.

void Magnum::Platform::Sdl2Application::textInputEvent(TextInputEvent& event) virtual protected

Text input event.

Called when text input is active and the text is being input.

void Magnum::Platform::Sdl2Application::textEditingEvent(TextEditingEvent& event) virtual protected

Text editing event.

Called when text input is active and the text is being edited.