Index: Classes

Action

Mousetrap.ActionType

Action <: SignalEmitter

Memory-managed object that wraps a function. Each action has a unique ID and is registered with the Application. It can furthermore have any number of shortcut triggers.

Use set_function! to register a callback to be called when the action is activated in any way. This function is required to have the signature:

(::Action, [::Data_t]) -> Nothing

Each action can be enabled or disabled. If an action is disabled, all associated widgets, keybindings and menu items will be disabled automatically.

See the manual chapter on actions for more information.

Constructors

Action(::ActionID, ::Application)
Action(stateless_f, ::ActionID, ::Application)

Signals

activated

(::Action, [::Data_t]) -> Nothing

Emitted when activate! is called, or the Action is otherwise activated.

Fields

(no public fields)

Example

action = Action("example.action", app)
set_function!(action) do self::Action
    println(get_id(self) * " activated.")
end
activate!(action)
source

Functions that operate on this type:


ActionBar

Mousetrap.ActionBarType

ActionBar <: Widget

Horizontal bar, has an area for widgets at the start and end, along with a singular centered widget, set via set_center_widget!. ActionBar can be hidden / shown using set_is_revealed!. It is always horizontal.

Constructors

ActionBar()

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


Adjustment

Mousetrap.AdjustmentType

Adjustment <: SignalEmitter

Object that represents a range of discrete values. Modifying the underlying adjustment of a widget will modify the widget, and vice-versa.

See get_adjustment to see which widgets are available to be controlled this way.

Constructors

Adjustment(value::Number, lower::Number, upper::Number, increment::Number)

Signals

value_changed

(::Adjustment, [::Data_t]) -> Nothing

Emitted when the value property of the Adjustment changes.

properties_changed

(::Adjustment, [::Data_t]) -> Nothing

Emitted when any property of the Adjustment other than value changes.

Fields

(no public fields)

source

Functions that operate on this type:


AlertDialog

Mousetrap.AlertDialogType

AlertDialog <: SignalEmitter

Simple dialog with a message, detailed description, space for a single widget, and one or more labeled buttons.

Use on_selection! to register a function with the signature

(::AlertDialog, button_index::Integer, [::Data_t]) -> Nothing

which is called when the user makes a selection or closes the dialog.

Constructors

AlertDialog(message::String, [detailed_message::String])

Signals

(no unique signals)

Fields

(no public fields)

Example

alert_dialog = AlertDialog("Is this is a dialog?")
add_button!(alert_dialog, "yes")
add_button!(alert_dialog, "no")
on_selection!(alert_dialog) do self::AlertDialog, button_index::Signed
    if button_index == 1
        println("User chose `Yes`")
    elseif button_index == 2
        println("User chose `No`")
    elseif button_index == 0
        println("User dismissed the dialog")
    end
end
present!(alert_dialog)
source

Functions that operate on this type:


Angle

Mousetrap.AngleType

Angle

Represents an angle in a unit-agnostic way.

Use radians or degrees to construct an object of this type.

as_radians and as_degrees allow for converting an angle to the respective unit.

Constructors

(no public constructors)

Fields

(no public fields)

source

Functions that operate on this type:


Animation

Mousetrap.AnimationType

Animation <: SignalEmitter

Object that provides a steady timing function which is synched to a widget's render cycle. It can be used as the basis of implementing animations.

Use on_tick! to register a callback with the signature

(::Animation, value::Float64, [::Data_t]) -> Nothing

Which will be called once per frame while the widget is visible.

By default, the animation's value will be in [0, 1], this can be changed with set_lower! and set_upper!. The shape of the function interpolating the value over time can be set using set_timing_function!.

Constructors

Animation(target::Widget, duration::Time)

Signals

(no unique signals)

Fields

(no public fields)

Example

# animate a gradual fade-out
to_animate = Button(Label("Click Me"))

animation = Animation(to_animate, seconds(1))

on_tick!(animation, to_animate) do self::Animation, value::AbstractFloat, target::Widget
    # value will be in [0, 1]
    set_opacity!(target, 1 - value)
end

on_done!(animation, to_animate) do self::Animation, target::Widget
    set_is_visible!(target, false)
end

# start animation when button is clicked
connect_signal_clicked!(to_animate, animation) do self::Button, animation::Animation
    play!(animation)
end

set_child!(window, to_animate)
source

Functions that operate on this type:


Application

Mousetrap.ApplicationType

Application <: SignalEmitter

Used to register an application with the user's OS.

The application's ID is required to contain at least one ., and it should be unique, meaning no other application on the users operating system shares this ID.

When all windows of an application are closed, or quit! is called, the application exits. This can be prevented with hold!, which has to be undone later by calling release!. When exiting, the application will emit signal shutdown, which should be used to safely free resources.

When creating a new application, allow_multiple_instances governs whether resources are shared between two instances with the same ID. If set to false, the most recently created instance will be the primary instance. If set to true (default) the instance created first will be the primary instance. See here for more information.

Constructors

Application(::ApplicationID; [allow_multiple_instances::Bool = true])

Signals

activate

(::Application, [::Data_t]) -> Nothing

Emitted when an activatable widget is activated by the user, usually by pressing the enter key.

shutdown

(::Application, [::Data_t]) -> Nothing

Emitted when an Application is exiting the main loop and attempting to shut down.

Fields

(no public fields)

Example

app = Application("example.app")
connect_signal_activate!(app) app::Application
    # all initialization has to happen here
end
connect_signal_shutdown!(app) app::Application
    # safely free all resources
end
run!(app)
source

Functions that operate on this type:


ApplicationID

Mousetrap.ApplicationIDType

ApplicationID

Application name as a string, in reverse domain name syntax. For example, if the app's homepage is Foo.julia.org, an appropriate application ID would be "org.julia.foo"

source

Functions that operate on this type:


AspectFrame

Mousetrap.AspectFrameType

AspectFrame <: Widget

Container widget with a single child, makes sure that the size of its child will always be at the specified width-to-height ratio.

Constructors

AspectFrame(width_to_height::AbstractFloat; [child_x_alignment::AbstractFloat, child_y_alignment::AbstractFloat])
AspectFrame(Width_to_height::AbstractFloat, child::Widget)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


AxisAlignedRectangle

Mousetrap.AxisAlignedRectangleType

AxisAlignedRectangle

Axis-aligned bounding box. Defined by its top-left corner and size.

Constructors

AxisAlignedRectangle(top_left::Vector2f, size::Vector2f)

Fields

  • top_left::Vectorf
  • size::Vector2f
source

Box

Mousetrap.BoxType

Box <: Widget

Widget that aligns its children in a row or column, depending on orientation.

Constructors

Box(::Orientation)

Signals

(no unique signals)

Fields

(no public fields)

Example

box = Box(ORIENTATION_HORIZONTAL)
push_back!(box, Label("01"))
push_back!(box, Button())
push_back!(box, Label("03"))

# equivalent to
box = hbox(Label("01"), Button(), Label("02"))
source

Functions that operate on this type:


Button

Mousetrap.ButtonType

Button <: Widget

Button with a label. Connect to signal clicked or specify an action via set_action! in order to react to the user clicking the button.

Constructors

Button()
Button(label::Widget)
Button(::Icon)

Signals

clicked

(::Button, [::Data_t]) -> Nothing

Emitted when the user clicks the widget using a mouse or touchscreen.

Fields

(no public fields)

Example

button = Button()
set_child!(button, Label("Click Me"))
connect_signal_clicked!(button) do x::Button
    println("clicked!")
end
set_child!(window, button)
source

Functions that operate on this type:


CenterBox

Mousetrap.CenterBoxType

CenterBox <: Widget

Widget that aligns exactly 3 widgets in a row (or column), prioritizing keeping the middle widget centered at all times.

Constructors

CenterBox(::Orientation)
CenterBox(::Orientation, left::Widget, center::Widget, right::Widget)

Signals

(no unique signals)

Fields

(no public fields)

Example

center_box = CenterBox(ORIENTATION_HORIZONTAL)
set_start_child!(center_box, Label("Left"))
set_center_child!(center_box, Button())
set_end_child!(center_box, Label("Right"))
source

Functions that operate on this type:


CheckButton

Mousetrap.CheckButtonType

CheckButton <: Widget

Rectangle that displays a checkmark and an optional label. Connect to signal toggled to react to the user changing the CheckButton's state by clicking it.

Constructors

CheckButton()

Signals

toggled

(::CheckButton, [::Data_t]) -> Nothing

Emitted when the widgets internal state changes from active to inactive, or inactive to active.

Fields

(no public fields)

Example

check_button = CheckButton()
set_child!(check_button, Label("Click Me"))
connect_signal_toggled!(check_button) do self::CheckButton
    state = get_state(self)
    print("CheckButton is now: ") 
    if state == CHECK_BUTTON_STATE_ACTIVE
        println("active!")
    elseif state == CHECK_BUTTON_STATE_INACTIVE
        println("inactive")
    else # state == CHECK_BUTTON_STATE_INCONSISTENT
        println("inconsistent")
    end
end
set_child!(window, check_button)
source

Functions that operate on this type:


ClampFrame

Mousetrap.ClampFrameType

ClampFrame <: Widget

Constrains its single child such that the child's width (or height, if vertically orientated) cannot exceed the size set using set_maximum_size!.

Constructors

ClampFrame(size_px::AbstractFloat, [::Orientation = ORIENTATION_HORIZONTAL])

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


ClickEventController

Mousetrap.ClickEventControllerType

ClickEventController <: SingleClickGesture <: EventController

Event controller that reacts to a series of one or more mouse-button or touchscreen presses.

Constructors

ClickEventController()

Signals

click_pressed

(::ClickEventController, n_presses::Integer, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

User presses a mouse button (which is currently not pressed), while the controllers associated widget holds input focus. Where n_presses are the current number of clicks in the sequence, x, y are the current cursor position, in pixels.

click_released

(::ClickEventController, n_presses::Integer, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

User releases a mouse button (which is currently pressed), while the controllers associated widget holds input focus. Where n_presses are the current number of clicks in the sequence, x, y are the current cursor position, in pixels.

click_stopped

(::ClickEventController, [::Data_t]) -> Nothing

Emitted exactly once to signal that a series of clicks ended.

Fields

(no public fields)

Example

click_controller = ClickEventController()
connect_signal_click_pressed!(click_controller) do self::ClickEventController, n_presses::Integer, x::Float64, y::Float64
    if n_presses == 2
        println("double click registered at position ($(Int64(x)), $(Int64(y)))")
    end
end
add_controller!(window, click_controller)
source

Functions that operate on this type:


Clipboard

Mousetrap.ClipboardType

Clipboard <: SignalEmitter

Allows for accessing and overwriting the data in the user's OS-wide clipboard. Construct an instance of this type by calling get_clipboard on the toplevel window.

If the clipboard contains an image, use get_image to access it, any other kind of data needs to be accesses with get_string.

Constructors

(no public constructors)

Signals

(no unique signals)

Fields

(no public fields)

Example

clipboard = get_clipboard(window)
get_string(clipboard) do self::Clipboard, value::String
    println("Value in clipboard: " * value)
end
source

Functions that operate on this type:


Clock

Mousetrap.ClockType

Clock <: SignalEmitter

Object used to keep track of time. Nanosecond precision.

Constructors

Clock()

Signals

(no unique signals)

Fields

(no public fields)

Example

clock = Clock()
current = restart!(clock)
sleep(1)
now = elapsed(clock)
println("time delta: $(as_seconds(now - current))")
source

Functions that operate on this type:


ColorChooser

Mousetrap.ColorChooserType

ColorChooser <: SignalEmitter

Dialog that allows a user to choose a color.

Constructors

ColorChooser([title::String, modal::Bool])

Signals

(no unique signals)

Fields

(no public fields)

Example

color_chooser = ColorChooser()
on_accept!(color_chooser) do self::ColorChooser, color::RGBA
    println("Selected $color")
end
on_cancel!(color_chooser) do self::ColorChooser
    println("color selection cancelled")
end
present!(color_chooser)
source

Functions that operate on this type:


ColumnView

Mousetrap.ColumnViewType

ColumnView <: Widget

Selectable widget that arranges its children as a table with rows and named columns.

Constructors

ColumnView([::SelectionMode])

Signals

activate

(::ColumnView, [::Data_t]) -> Nothing

Emitted when an activatable widget is activated by the user, usually by pressing the enter key.

Fields

(no public fields)

Example

column_view = ColumnView(SELECTION_MODE_NONE)

for column_i in 1:4
    column = push_back_column!(column_view, "Column #$column_i")
    for row_i in 1:3
        set_widget!(column_view, column, row_i, Label("$row_i | $column_i"))
    end
end

# or push an entire row at once
push_back_row!(column_view, Button(), CheckButton(), Entry(), Separator())        
set_child!(window, column_view)
source

Functions that operate on this type:


ColumnViewColumn

Mousetrap.ColumnViewColumnType

ColumnViewColumn <: SignalEmitter

Class representing a column of ColumnView. Has a label, any number of children which represented that columns rows, and an optional header menu.

Constructors

(no public constructors)

Signals

(no unique signals)

Fields

(no public fields)

Example

# create a new column
column = push_back_column!(column_view)

# set widget in 4th row, automatically backfills rows 1 - 3
set_widget!(column, 4, Label("4"))
source

Functions that operate on this type:


DragEventController

Mousetrap.DragEventControllerType

DragEventController <: SingleClickGesture <: EventController

Event controller that recogizes drag-gestures by both a mouse or touch device.

Constructors

DragEventController()

Signals

drag_begin

(::DragEventController, start_x::AbstractFloat, start_y::AbstractFloat, [::Data_t]) -> Nothing

Emitted exaclty once, on the first frame a drag gesture is recognized, where start_y and start_x are the initial position of the cursor, in pixels.

drag

(::DragEventController, x_offset::AbstractFloat, y_offset::AbstractFloat, [::Data_t]) -> Nothing

Emitted once per frame while a drag gesture is active, where x_offset and y_offset are the distance between the current position of the cursor, and the position at the start of the gesture, in pixels.

drag_end

(::DragEventController, x_offset::AbstractFloat, y_offset::AbstractFloat, [::Data_t]) -> Nothing

Emitted exactly once, when the drag gesture seizes to be active, where x_offset and y_offset are the distance between the current position of the cursor, and the position at the start of the gesture, in pixels.

Fields

(no public fields)

Example

drag_controller = DragEventController()
connect_signal_drag!(drag_controller) do self::DragEventController, x_offset, y_offset
    start::Vector2f = get_start_position(self)
    current = start + Vector2f(x_offset, y_offset)
    println("Current cursor position: $current")
end
add_controller!(window, drag_controller)
source

Functions that operate on this type:


Mousetrap.DropDownType

DropDown <: Widget

Presents the user with a collapsible list of items. If one of its items is clicked, that item's callback will be invoked.

Constructors

DropDown()

Signals

(no unique signals)

Fields

(no public fields)

Example

drop_down = DropDown()
push_back!(drop_down, "Item 01") do x::DropDown
    println("Item 01 selected") 
end
push_back!(drop_down, "Item 02") do x::DropDown
    println("Item 02 selected") 
end
set_child!(window, drop_down)
source

Functions that operate on this type:


Mousetrap.DropDownItemIDType

DropDownItemID

ID of a dropdown item, returned when adding a new item to the drop down. Keep track of this in order to identify items in a position-independent manner.

Constructors

(no public constructors)

Fields

(no public fields)

source

Functions that operate on this type:


Entry

Mousetrap.EntryType

Entry <: Widget

Single-line text entry, supports "password mode", as well as inserting an icon to the left and/or right of the text area.

Constructors

Entry()

Signals

activate

(::Entry, [::Data_t]) -> Nothing

Emitted when an activatable widget is activated by the user, usually by pressing the enter key.

text_changed

(::Entry, [::Data_t]) -> Nothing

Emitted when underlying text buffer is modified in any way.

Fields

(no public fields)

Example

entry = Entry()
set_text!(entry, "Write here")
connect_signal_text_changed!(entry) do self::Entry
    println("text is now: $(get_text(self))")
end
source

Functions that operate on this type:


EventController

Mousetrap.EventControllerType

EventController <: SignalEmitter

Superclass of all event controllers. Use add_controller! to connect an event controller to any widget, after which it starts receiving input events. Connect to the unique signals of each event controller in order to react to these events.

Supertype

Any

Subtypes

source

Functions that operate on this type:


Expander

Mousetrap.ExpanderType

Expander <: Widget

Collapsible item which has a label and child. If the label is clicked, the child is shown (or hidden, if it is already shown).

Note

This widget should not be used to create collapsible lists, use ListView for this purpose instead.

Constructors

Expander()
Expander(child::Widget, label::Widget)

Signals

activate

(::Expander, [::Data_t]) -> Nothing

Emitted when an activatable widget is activated by the user, usually by pressing the enter key.

Fields

(no public fields)

source

Functions that operate on this type:


FileChooser

Mousetrap.FileChooserType

FileChooser <: SignalEmitter

Pre-made dialog that allows users to pick a file or folder on the local disk.

Connect a function with the signature

(::FileChooser, files::Vector{FileDescriptor}, [::Data_t]) -> Nothing

using on_accept!. When the user makes a selection, this function will be invoked and files will contain one or more selected files.

The file choosers layout depends on the FileChooserAction specified on construction.

Constructors

FileChooser(::FileChooserAction, [title::String])

Signals

(no unique signals)

Fields

(no public fields)

Example

file_chooser = FileChooser(FILE_CHOOSER_ACTION_OPEN_FILE)

on_accept!(file_chooser) do x::FileChooser, files::Vector{FileDescriptor}
    if !isempty(files)
        println("Selected file at ", get_path(files[1]))
    end
end

on_cancel!(file_chooser) do x::FileChooser
    println("Canceled.")
end

present!(file_chooser)
source

Functions that operate on this type:


FileDescriptor

Mousetrap.FileDescriptorType

FileDescriptor <: SignalEmitter

Read-only object that points a specific location on disk. There is no guaruantee that this location contains a valid file or folder.

Constructors

FileDescriptor(path::String)

Signals

(no unique signals)

Fields

(no public fields)

Example

current_dir = FileDescriptor(".")
for file in get_children(current_dir)
    println(get_name(file) * ":	" * get_content_type(file))
end
source

Functions that operate on this type:


FileFilter

Mousetrap.FileFilterType

FileFilter <: SignalEmitter

Filter used by FileChooser. Only files that pass the filter will be available to be selected when the file chooser is active.

If multiple filters are supplied, the user can select between them using a dropdown that is automatically added to the FileChooser dialog.

Constructors

FileFilter(name::String)

Signals

(no unique signals)

Fields

(no public fields)

Example

julia filter = FileFilter() add_allowed_suffix!(filter, "jl") # without the `.``

source

Functions that operate on this type:


FileMonitor

Mousetrap.FileMonitorType

FileMonitor <: SignalEmitter

Object that monitors a location on disk. If anything about the object at that location changes, it invoke the callback registered using on_file_changed!, which requires a function with signature

(::FileMonitor, event::FileMonitorEvent, self::FileDescriptor, other::FileDescriptor, [::Data_t]) -> Nothing

Where event classifies the type of change, self is the file being monitored.

Constructors

(no public constructors)

Signals

(no unique signals)

Fields

(no public fields)

Example

file = FileDescriptor("path/to/file.jl")
@assert(exists(file))
monitor = create_monitor(file)
on_file_changed!(monitor) do x::FileMonitor, event_type::FileMonitorEvent, self::FileDescriptor, other::FileDescriptor
    if event_type == FILE_MONITOR_EVENT_CHANGED
        println("File at " * get_path(self) * " was modified.")
    end
end
source

Functions that operate on this type:


Fixed

Mousetrap.FixedType

Fixed <: Widget

Container widget that places its children at a specified pixel position relative to the Fixeds top-left corner.

Use of this widget is usually discouraged, it does not allow for automatic expansion or alignment.

Constructors

Fixed()

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


FlowBox

Mousetrap.FlowBoxType

FlowBox <: Widget

Box-like widget that dynamically rearranges its children into multiple rows (or columns), as the widgets width (or height) changes.

Constructors

FlowBox(Orientation)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


FocusEventController

Mousetrap.FocusEventControllerType

FocusEventController <: EventController

Reacts to a widget gaining or loosing input focus.

Constructors

FocusEventController()

Signals

focus_gained

(::FocusEventController, [::Data_t]) -> Nothing

Emitted when the widget that is currently not focused becomes focus.

focus_lost

(::FocusEventController, [::Data_t]) -> Nothing

Emitted when the widget that is currently focused looses focus.

Fields

(no public fields)

Example

focus_controller = FocusEventController()
connect_signal_focus_gained!(focus_controller) do self::FocusController
    println("Gained Focus")
end
add_controller!(widget, focus_controller)
source

Functions that operate on this type:


Frame

Mousetrap.FrameType

Frame <: Widget

Widget that draws a black outline with rounded corners around its singular child.

Constructors

Frame()
Frame(child::Widget)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


FrameClock

Mousetrap.FrameClockType

FrameClock <: SignalEmitter

Clock that is synched with a widget's render cycle. Connect to its signals to trigger behavior once per frame.

Constructors

(no public constructors)

Signals

(no unique signals)

Fields

(no public fields)

Example

frame_clock = get_frame_clock(widget)
connect_signal_paint!(frame_clock) do x::FrameClock
    println("Widget was drawn.")
end
source

Functions that operate on this type:


GLArea

Mousetrap.GLAreaType

GLArea <: Widget

Canvas that can be used a an OpenGL render target. This widget is intended to be used by third libraries, if you want to render using OpenGL using only Mousetrap, use RenderArea instead.

Constructors

GLArea()

Signals

render

(::GLArea, gdk_gl_context::Ptr{Cvoid}, [::Data_t]) -> Bool

Emitted once per frame before the GL framebuffer is flushed to the screen. The gdk_gl_context argument is for internal use only and can be ignored.

resize

(::GLArea, width::Integer, height::Integer, [::Data_t]) -> Nothing

Emitted whenver the allocated area of a RenderArea changes, where width and height are the new size, in pixels.

Fields

(no public fields)

Example

canvas = GLArea()
connect_signal_resize!(canvas) do self::GLArea, x, y
    # viewport was resized to x, y (in pixels)
end 
connect_signal_render!(canvas) do self::GLArea, gl_context::Ptr{Cvoid}
    make_current!(canvas)
    # do OpenGL rendering here
    return true 
end
source

Functions that operate on this type:


GLTransform

Mousetrap.GLTransformType

GLTransform <: SignalEmitter

Transform in 3D spaces. Uses OpenGL coordinates, it should therefore only be used to modify vertices of a Shape.

Can be indexed and modified as a 4x4 matrix of Float32.

Constructors

GLTransform()

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


Grid

Mousetrap.GridType

Grid <: Widget

Selectable container that arranges its children in a non-uniform grid. Each child has a row- and column-index, as well as a width and height, measured in number of cells.

Constructors

Grid()

Signals

(no unique signals)

Fields

(no public fields)

Example

grid = Grid()
insert_at!(grid, Label("Label"), 1, 1, 1, 1)
insert_at!(grid, Button(), 1, 2, 1, 1)
insert_at!(grid, Separator, 2, 1, 2, 1)
source

Functions that operate on this type:


GridView

Mousetrap.GridViewType

GridView <: Widget

Selectable widget container that arranges its children in a uniform grid.

Constructors

GridView(::Orientation, [::SelectionMode])

Signals

activate_item

(::GridView, index::Integer, [::Data_t]) -> Nothing

Emitted when the user presses the enter key while one or more items are selected.

Fields

(no public fields)

source

Functions that operate on this type:


GroupID

Mousetrap.GroupIDType

GroupID

ID of a group inside a KeyFile. May not start with a number, and can only roman letters, 0-9, _, -, and ..

Use . to deliminate nested groups, as each key-value pair has to belong to exactly one group.

Constructors

(no public constructors)

Fields

(no public fields)

source

Functions that operate on this type:


HSVA

Mousetrap.HSVAType

HSVA

Color in hsva format, all components are Float32 in [0, 1].

Constructors

HSVA(::AbstractFloat, ::AbstractFloat, ::AbstractFloat, ::AbstractFloat)

Fields

  • h::Float32
  • s::Float32
  • v::Float32
  • a::Float32
source

Functions that operate on this type:


HeaderBar

Mousetrap.HeaderBarType

HeaderBar <: Widget

Widget that usually used as the title bar of a window. It contains a title, close-, maximize-, minimize buttons, as well as an area for widgets on both sides of the title.

Constructors

HeaderBar()
HeaderBar(layout::String)

Signals

(no unique signals)

Fields

(no public fields)

Example

header_bar = HeaderBar("close:title,minimize,maximize")
push_front!(header_bar, Button())
set_titlebar_widget!(window, header_bar)
source

Functions that operate on this type:


Icon

Mousetrap.IconType

Icon

Allows loading of icons from a image file or icon theme.

Constructors

Icon()
Icon(path::String)
Icon(theme::IconTheme, id::IconID, square_resolution::Integer)

Fields

(no public fields)

source

Functions that operate on this type:


IconID

Mousetrap.IconIDType

IconID

ID of an icon, used by IconTheme to refer to icons in a file-agnostic way.

Constructors

(no public constructors)

Fields

(no public fields) )

source

Functions that operate on this type:


IconTheme

Mousetrap.IconThemeType

IconTheme <: Any

Allows loading of items from a folder if that folder strictly adheres to the freedesktop icon theme specifications.

A Window is required to construct the icon theme, at which point the default icons for that windows display are also loaded.

Constructors

IconTheme(::Window)

Fields

(no public fields)

Example

theme = IconTheme()
add_resource_path!(theme, "/path/to/freedesktop_icon_theme_directory")

icon = Icon()
create_from_theme!(icon, theme, "custom-icon-id", 64)
source

Functions that operate on this type:


Image

Mousetrap.ImageType

Image <: Any

2D image data, in RGBA.

Constructors

Image()
Image(path::String)
Image(width::Integer, height::Integer, [::RGBA])

Fields

(no public fields)

source

Functions that operate on this type:


ImageDisplay

Mousetrap.ImageDisplayType

ImageDisplay <: Widget

Widget that displays an Image, Icon, or image file.

Constructors

ImageDisplay(path::String)
ImageDisplay(::Image)
ImageDisplay(::Icon)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


KeyCode

Functions that operate on this type:


KeyEventController

Mousetrap.KeyEventControllerType

KeyEventController <: EventController

Event controller that recognizes keyboard key strokes.

Constructors

KeyEventController()

Signals

key_pressed

(::KeyEventController, code::KeyCode, modifiers::ModifierState, [::Data_t]) -> Nothing

Emitted when the user presses a non-modifier key (which is currently not pressed), while the controllers associated widget holds input focus.

key_released

(::KeyEventController, code::KeyCode, modifiers::ModifierState, [::Data_t]) -> Nothing

Emitted when the user releases a non-modifier key (which is currently pressed), while the controllers associated widget holds input focus.

modifiers_changed

(::KeyEventController, modifiers::ModifierState, [::Data_t]) -> Nothing

Emitted when the user presses or releases a modifier key, while the controllers associated widget holds input focus.

Fields

(no public fields)

Example

key_controller = KeyEventController()
connect_signal_key_pressed!(key_controller) do self::KeyEventController, key::KeyCode, modifier::ModifierState
    if key == KEY_space
        println("space bar pressed")
    end
end
add_controller!(window, key_controller)
source

Functions that operate on this type:


KeyFile

Mousetrap.KeyFileType

KeyFile <: SignalEmitter

GLib keyfile, ordered into groups with key-value pairs.

Allows (de-)serializing of the following types:

  • Bool, Vector{Bool}
  • AbstractFloat, Vector{AbstractFloat}
  • Signed, Vector{Signed}
  • Unsigned, Vector{Unsigned}
  • String, Vector{String}
  • RGBA
  • HSVA
  • Image

All key-values pairs have to be in exactly one group.

Constructors

KeyFile()
KeyFile(path::String)

Signals

(no unique signals)

Fields

(no public fields)

Example

key_file = KeyFile()
set_value!(key_file, "group_id", "key_id", [123, 456, 789])
set_comment_above!(key_file, "group_id", "key_id", "An example key-value pair")
println(as_string(key_file))

``` [group_id]

An example key-value pair

key_id=123;456;789; ````

source

Functions that operate on this type:


KeyID

Mousetrap.KeyIDType

KeyID

ID of KeyFile key-value-pair. Contains only roman letters, 0-9, and '_'.

Constructors

(no public constructors)

Fields

(no public fields)

source

Functions that operate on this type:


Label

Functions that operate on this type:


LevelBar

Mousetrap.LevelBarType

LevelBar <: Widget

Non-interactive widget that displays the value of a range as a fraction.

Constructors

LevelBar(min::AbstractFloat, max::AbstractFloat)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


ListView

Mousetrap.ListViewType

ListView <: Widget

Selectable widget container that arranges its children in a (nested) list.

Constructors

ListView(::Orientation, [::SelectionMode])

Signals

activate_item

(::ListView, index::Integer, [::Data_t]) -> Nothing

Emitted when the user presses the enter key while one or more items are selected.

Fields

(no public fields)

Example

list_view = ListView(ORIENTATION_VERTICAL)

item_01_iterator = push_back!(list_view, Label("Item 01"))
push_back!(list_view, Label("Item 02"))
push_back!(list_view, Label("Imte 03"))

push_back!(list_view, Label("Nested Item 01"), item_01_iterator)
push_back!(list_view, Label("Nested Item 02"), item_01_iterator)

set_child!(window, list_view)
source

Functions that operate on this type:


ListViewIterator

Mousetrap.ListViewIteratorType

ListViewIterator

Iterator returned when inserting an item into a ListView. Use this iterator as an additional argument to push_back!, push_front!, or insert, in order to create a nested list at that item position.

Constructors

(no public constructors)

Fields

(no public fields)

source

Functions that operate on this type:


LogDomain

Mousetrap.LogDomainType

LogDomain

Domain of log messages, this will be used to associate log message with a specific application or library. May only contain roman letters, _, . and -.

Constructors

LogDomain(::String)

Fields

(no public fields)

source

Functions that operate on this type:


LongPressEventController

Mousetrap.LongPressEventControllerType

LongPressEventController <: SingleClickGesture <: EventController

Event controller that recognizes long-press-gestures from a mouse or touch device.

Constructors

LongPressEventController()

Signals

pressed

(::LongPressEventController, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

Emitted once when a long-press gesture is recognized, where x and y are the current position of the cursor, in pixels.

press_cancelled

(::LongPressEventController, [::Data_t]) -> Nothing

Emitted once when the user releases the button of a long-press gesture.

Fields

(no public fields)

Example

long_press_controller = LongPressEventController()
connect_signal_pressed!(long_press_controller) do self::LongPressEventController, x::AbstractFloat, y::AbstractFloat 
    println("long press recognized at ($x, $y)")
end
add_controller!(window, long_press_controller)
source

Functions that operate on this type:


Mousetrap.MenuBarType

MenuBar <: Widget

View that displays a MenuModel as a horizontal bar.

The MenuModel has to have the following structure:

  • all top-level items have to be "submenu"-type items
  • no submenu or section of another submenu may have a "widget"-type item

Constructors

HeaderBar(::MenuModel)

Signals

(no unique signals)

Fields

(no public fields)

Example

action = Action("example.action", app)
set_function!(action) do action::Action
    println(get_id(action), " activate.")
end

outer_model = MenuModel()
inner_model = MenuModel()
add_action!(inner_model, "Trigger Action", action)
add_submenu!(outer_model, "Submenu", inner_model)

menu_bar = MenuBar(outer_model)
set_child!(window, menu_bar)
source

Functions that operate on this type:


Mousetrap.MenuModelType

MenuModel <: SignalEmitter

Model that holds information about how to construct a menu.

Use MenuBar or PopoverMenu to display the menu to the user.

The following types of menu items are available

TypeFunction
"action"add_action!(::MenuModel, label::String, ::Action)
"icon"add_icon!(::MenuModel, ::Icon, ::Action)
"submenu"add_submenu!(::MenuModel, label::String, other::MenuModel)
"section"add_section!(::MenuModel, label::String, other::MenuModel)
"widget"add_widget!(::MenuModel, ::Widget)

See the manual section on menus for more information.

Constructors

MenuModel()

Signals

items_changed

(::MenuModel, position::Integer, n_removed::Integer, n_added::Integer, [::Data_t]) -> Nothing

Emitted when the number of menu items, or any of their properties, changes.

Fields

(no public fields)

source

Functions that operate on this type:


ModifierState

Mousetrap.ModifierStateType

ModifierState

Holds information about which modifier are currently pressed

See also:

Constructors

(no public constructors)

Fields

(no public fields)

Example

key_controller = KeyEventController()
connect_signal_modifiers_changed!(key_controller) do self::KeyEventController, modifiers::ModifierState
    if shift_pressed(modifiers)
        println("Shift was pressed")
    end
end
add_controller!(window, key_controller)
source

Functions that operate on this type:


MotionEventController

Mousetrap.MotionEventControllerType

MotionEventController <: EventController

Captures cursor motion events while the cursor is inside the allocated area of the associated widget.

Constructors

MotionEventController()

Signals

motion_enter

(::MotionEventController, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

Emitted once when the users cursor first enters the allocated area of the widget on screen, where x and y are the current position of the cursor, in pixels.

motion

(::MotionEventController, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

Emitted once per frame, while the cursor is inside the allocated area of the widget, where x and y are the current cursor position, in pixels.

motion_leave

(::MotionEventController, [::Data_t]) -> Nothing

Emitted exactly once when the cursor leaves the allocated area of the widget.

Fields

(no public fields)

Example

motion_controller = MotionEventController()
connect_signal_motion!(motion_controller) do self::MotionEventController, x::AbstractFloat, y::AbstractFloat
    println("recognized motion at ($(Int64(round(x))), $(Int64(round(y))))")
end
add_controller!(window, motion_controller)
source

Functions that operate on this type:


Notebook

Mousetrap.NotebookType

Notebook <: Widget

Widget that arranges its children as a list of pages. Each page has exactly one child widget, as well as an optional label widget. Pages can be freely reordered by the user if set_tabs_reorderable! is set to true. It furthermore supports a quick-change menu, in which the user can quickly jump to another tab. To enable this, set_quick_change_menu_enabled! needs to be set to true.

Constructors

Notebook()

Signals

page_added

(::Notebook, page_index::Integer, [::Data_t]) -> Nothing

Emitted when the total number of pages increases, where page_index is the position of the page that was inserted.

page_removed

(::Notebook, page_index::Integer, [::Data_t]) -> Nothing

Emitted when a page is removed, where page_index is the old index of the page that was removed.

page_reordered

(::Notebook, page_index::Integer, [::Data_t]) -> Nothing

Emitted when a page changes position, where page_index is the new position of the page.

page_selection_changed

(::Notebook, page_index::Integer, [::Data_t]) -> Nothing

Emitted when the currently active page changes by any means, where page_index is the index of the now visible page.

Fields

(no public fields)

Example

notebook = Notebook()
push_back!(notebook, Separator(), Label("Page 01"))
push_back!(notebook, Separator(), Label("Page 02"))

connect_signal_page_selection_changed!(notebook) do x::Notebook, index::Integer
    println("Page #$index is now selected")
end

set_child!(window, notebook)
source

Functions that operate on this type:


Overlay

Mousetrap.OverlayType

Overlay <: Widget

Widget that has exaclty one "base" child, and any number of "overlay" children. If two interactable widgets overlap, only the top-most widget will be interactable.

Constructors

Overlay()
Overlay(base::Widget, overlays::Widget...)

Signals

(no unique signals)

Fields

(no public fields)

Example

overlay = Overlay()
set_child!(overlay, Separator())
add_overlay!(overlay, Label("On Top"))    
set_child!(window, overlay)
source

Functions that operate on this type:


PanEventController

Mousetrap.PanEventControllerType

PanEventController <: SingleClickGesture <: EventController

Recognizes pan gestures along exactly one axis.

Constructors

PanEventController(axis::Orientation)

Signals

pan

(::PanEventController, ::PanDirection, offset::AbstractFloat, [::Data_t]) -> Nothing

Emitted once per frame while a pan gesture is active, where offset is the horizontal (or vertical) distance between the current position of the cursor, and the position at the start of the gesture, in pixels.

Fields

(no public fields)

Example

connect_signal_pan!(pan_controller) do self::PanEventController, direction::PanDirection, offset::AbstractFloat
    if direction == PAN_DIRECTION_LEFT
        println("panning left")
    elseif direction == PAN_DIRECTION_RIGHT
        println("panning right")
    end
    println("x-offset from start position: $offset")
end
add_controller!(window, pan_controller)
source

Functions that operate on this type:


Paned

Mousetrap.PanedType

Paned <: Widget

Widget with exactly two children. Draws a solid border between the two, which the user can drag to one side or the other to control the size of both widgets at the same time.

Constructors

Paned(orientation::Orientation)
Paned(orientation::Orientation, start_child::Widget, end_child::Widget)

Signals

(no unique signals)

Fields

(no public fields)

Example

paned = Paned(ORIENTATION_HORIZONTAL)
set_start_child!(paned, Label("Left"))
set_end_child!(paned, Label("Right"))
source

Functions that operate on this type:


PinchZoomEventController

Mousetrap.PinchZoomEventControllerType

PinchZoomEventController <: EventController

Controller recognizing 2-finger pinch-zoom gestures (touch-only).

Constructors

PinchZoomEventController()

Signals

scale_changed

(::PinchZoomEventController, scale::AbstractFloat, [::Data_t]) -> Nothing

Emitted any time the distance between two fingers of a pinch-zoom-gesture changes, where scale is the factor of the current distance between the two fingers, compared to the distance at the start of the gesture.

Fields

(no public fields)

Example

pinch_zoom_controller = PinchZoomEventController()
connect_signal_scale_changed!(pinch_zoom_controller) do self::PinchZoomEventController, scale::AbstractFloat
    println("current scale: $scale")
end
add_controller!(window, pinch_zoom_controller)
source

Functions that operate on this type:


Popover

Mousetrap.PopoverType

Popover <: Widget

Window-type widget with exactly one child, has to be attached to another widget to be visible. Use PopoverButton to automatically show / hide the popover.

Constructors

Popover()

Signals

closed

(::Popover, [::Data_t]) -> Nothing

Emitted when a popover-window is closed, for example by calling popdown!, or it loosing focus while set_autohide! is set to true.

Fields

(no public fields)

Example

popover = Popover()
set_child!(popover, Label("Popover!"))

popover_button = PopoverButton()
set_popover!(popover_button, popover)

set_child!(window, popover_button)
source

Functions that operate on this type:


PopoverButton

Mousetrap.PopoverButtonType

PopoverButton <: Widget

Button that automatically shows or hides its associated Popover or PopoverMenu when clicked.

Constructors

PopoverButton(::Popover)
PopoverButton(::PopoverMenu)

Signals

(no unique signals)

Fields

(no public fields)

Example

popover = Popover()
set_child!(popover, Label("Popover!"))

popover_button = PopoverButton()
set_popover!(popover_button, popover)

set_child!(window, popover_button)
source

Functions that operate on this type:


PopoverMenu

Mousetrap.PopoverMenuType

PopoverMenu <: Widget

Menu view that display a MenuModel in a popover window. Use PopoverButton to automatically show / hide the popover.

Constructors

PopoverMenu(::MenuModel)

Signals

closed

(::PopoverMenu, [::Data_t]) -> Nothing

Emitted when a popover-window is closed, for example by calling popdown!, or it loosing focus while set_autohide! is set to true.

Fields

(no public fields)

Example

action = Action("example.action", app)
set_function!(action) do x::Action
    println("Action activated")
end

model = MenuModel()
add_action!(model, "Trigger Example", action)

popover_menu = PopoverMenu(model)
popover_button = PopoverButton()
set_popover_menu!(popover_button, popover_menu)

set_child!(window, popover_button)
source

Functions that operate on this type:


PopupMessage

Mousetrap.PopupMessageType

PopupMessage <: SignalEmitter

Popup message, always has a title and a close button. Additionally, a singular optional button can be placed next to the title. When clicked, the PopupMessage emits signal button_clicked, or calls the Action connected to the button using set_button_action!.

Use PopupMessageOverlay to display the message above a widget.

Constructors

PopupMessage(title::String)
PopupMessage(title::String, button_label::String)

Signals

dismissed

(::PopupMessage, [::Data_t]) -> Nothing

Emitted when the user clicks the close button of the PopupMessage

button_clicked

(::PopupMessage, [::Data_t]) -> Nothing

Emitted when the user clicks the button of a PopupMessage. Note that the button is only visible if set_button_label! was set to anything but ""

Fields

(no public fields)

Example

message_overlay = PopupMessageOverlay()
set_child!(message_overlay, Separator())

message = PopupMessage("Is this a message?", "Yes")
connect_signal_button_clicked!(message) do self::PopupMessage
    println("button clicked")
end
connect_signal_dismissed!(message) do self::PopupMessage
    println("message closed")
end

show_message!(message_overlay, message)
source

Functions that operate on this type:


PopupMessageOverlay

Mousetrap.PopupMessageOverlayType

PopupMessageOverlay <: SignalEmitter

Widget that can display a PopupMessage above the PopupMessageOverlay's singular child. Only one message can be shown at a time.

Constructors

PopupMessageOverlay()

Signals

(no unique signals)

Fields

(no public fields)

Example

overlay = PopupMessageOverlay()
set_child!(overlay, widget)

message = PopupMessage("This example works!", "ok")
connect_signal_button_clicked!(message) do self::PopupMessage
    println("button clicked")
end
connect_signal_dismissed!(message) do self::PopupMessage
    println("message closed")
end

show_message!(overlay, message)
source

Functions that operate on this type:


ProgressBar

Mousetrap.ProgressBarType

ProgressBar <: Widget

Bar that displays a fraction in [0, 1]. Use set_fraction! to change the current value.

Constructors

ProgressBar()

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


RGBA

Mousetrap.RGBAType

RGBA

Color representation in rgba. All components are Float32 in [0, 1].

Constructors

RGBA(r::AbstractFloat, g::AbstractFloat, b::AbstractFloat, a::AbstractFloat)

Fields

  • r::Float32
  • g::Float32
  • b::Float32
  • a::Flota32
source

Functions that operate on this type:


RenderArea

Mousetrap.RenderAreaType

RenderArea <: Widget

Canvas for rendering custom shapes.

See the manual chapter on native rendering for more information.

Constructors

RenderArea([AntiAliasingQuality = ANTI_ALIASING_QUALITY_OFF])

Signals

resize

(::RenderArea, width::Integer, height::Integer, [::Data_t]) -> Nothing

Emitted whenver the allocated area of a RenderArea changes, where width and height are the new size, in pixels.

Fields

(no public fields)

Example

render_area = RenderArea()
rectangle = Rectangle(Vector2f(-0.5, -0.5), Vector2f(1, 1))
add_render_task!(render_area, RenderTask(rectangle))
set_size_request!(render_area, Vector2f(150, 150))
set_child!(window, render_area)
source

Functions that operate on this type:


RenderTask

Mousetrap.RenderTaskType

RenderTask <: SignalEmitter

Task that groups a Shape, Shader, [GLTransform]@ref, and BlendMode, allowing them to be bound for rendering.

If no shader, transform, and/or blend mode is specified, the default shader, identity transform, and BLEND_MODE_NORMAL will be used, respectively.

See the manual chapter on native rendering for more information.

Constructors

RenderTask(::Shape; [shader::Union{Shader, Nothing}, transform::Union{GLTransform, Nothing}, blend_mode::BlendMode])

Signals

(no unique signals)

Fields

(no public fields)

Example

shape = Rectangle(Vector2f(-0.5, -0.5), Vector2f(1, 1))
task = RenderTask(shape)

# euivalent to

task = RenderTask(shape;
    shader = nothing,
    transform = nothing,
    blend_mode = BLEND_MODE_NORMAL
)
source

Functions that operate on this type:


RenderTexture

Mousetrap.RenderTextureType

RenderTexture <: TextureObject <: SignalEmitter

Texture that can be bound as a render target. This object is for internal use only.

Constructors

RenderTexture()

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


Revealer

Mousetrap.RevealerType

Revealer <: Widget

Container that plays an animation to reveal or hide its singular child.

Constructors

Revealer([::RevealerTransitionType])
Revealer(child::Widget, [::RevealerTransitionType])

Signals

revealed

(::Revealer, [::Data_t]) -> Nothing

Emitted once when a Revealers child goes from hidden to shown (or shown to hidden) and the corresponding animation has finished playing.

Fields

(no public fields)

source

Functions that operate on this type:


RotateEventController

Mousetrap.RotateEventControllerType

RotateEventController <: EventController

Recognizes 2-finger rotate gestures (touch-only).

Constructors

RotateEventController()

Signals

rotation_changed

(::RotateEventController, angle_absolute::AbstractFloat, angle_delta::AbstractFloat, [::Data_t]) -> Nothing

Emitted when the angle between the two fingers of a rotate-gesture changes, where angle_delta is the offset, angle_absolute the current angle, in radians.

Fields

(no public fields)

Example

rotate_controller = RotateEventController()
connect_signal_rotation_changed!(rotate_controller) do self::RotateEventController, angle_absolute::AbstractFloat, angle_dela::AbstractFloat
    println("angle is now: " * as_degrees(radians(angle_absolute)) * "°")
end
add_controller!(window, rotate_controller)
source

Functions that operate on this type:


Scale

Mousetrap.ScaleType

Scale <: Widget

Allows users to select a value from a range.

Constructors

Scale(lower::AbstractFloat, upper::AbstractFloat, step_increment::AbstractFloat, [::Orientation])

Signals

value_changed

(::Scale, [::Data_t]) -> Nothing

Emitted when the value property of the Adjustment changes.

Fields

(no public fields)

Example

scale = Scale(0, 1, 0.01)
connect_signal_value_changed!(scale) self::Scale
    println("Current value: $(get_value(scale))")
end
source

Functions that operate on this type:


ScrollEventController

Mousetrap.ScrollEventControllerType

ScrollEventController <: EventController

Controller recognizing scrolling gestures by a mouse scrollwheel or touch device.

Constructors

ScrollEventController([kinetic_scrolling_enabled::Bool = false])

Signals

scroll_begin

(::ScrollEventController, [::Data_t]) -> Nothing

Emitted once when a scroll gesture is first recognized.

scroll

(::ScrollEventController, x_delta::AbstractFloat, y_delta::AbstractFloat, [::Data_t]) -> Nothing

Emitted once per frame while a scroll gesture is active, where x_delta and y_delta are the offset along the horizontal and vertical axis, in pixels.

scroll_end

(::ScrollEventController, [::Data_t]) -> Nothing

Emitted to signal the end of a scroll gesture.

kinetic_scroll_decelerate

(::ScrollEventController, x_velocity::AbstractFloat, y_velocity::AbstractFloat, [::Data_t]) -> Nothing

Emitted once per frame while kinetic scrolling is active, see the manual on ScrollEventController for more information.

Fields

(no public fields)

Example

scroll_controller = ScrollEventController()
connect_signal_scroll!(scroll_controller) do self::ScrollEventController, delta_x::AbstractFloat, delta_y::AbstractFloat
    println("current scroll offset: ($delta_x, $delta_y)")
end
add_controller!(window, scroll_controller)
source

Functions that operate on this type:


Scrollbar

Mousetrap.ScrollbarType

Scrollbar <: Widget

GUI element typically used to scroll another widget. Connect to the signals of the underlying adjustment to react to the user scrolling.

Constructors

Scrollbar(::Orientation, ::Adjustment)

Signals

(no unique signals)

Fields

(no public fields)

Example

```julia scrollbar = Scrollbar(ORIENTATIONHORIZONTAL, Adjustment(0, 0, 1, 0.01)) connectsignalvaluechanged!(getadjustment(scrollbar)) do self::Adjustment println("value is now $(Expr(:incomplete, "incomplete: premature end of input"))value(self))") end

source

Functions that operate on this type:


SelectionModel

Mousetrap.SelectionModelType

SelectionModel <: SignalEmitter

Model that governs the current selection of a selectable widget, such as GridView, ListView, or Stack.

Only if the selection mode is set to anything other than SELECTION_MODE_NONE will the selection model emit its signals.

Use get_selection_model to retrieve the model from a selectable widget.

Constructors

(no public constructors)

Signals

selection_changed

(::SelectionModel, position::Integer, n_items::Integer, [::Data_t]) -> Nothing

The number or position of one or more selected items has changed, where position is the item index that was modified, n_items is the number of items currently selected.

Fields

(no public fields)

Example

grid_view = GridView(SELECTION_MODE_SINGLE)
for i in 1:4
    push_back!(grid_view, Label("0$i"))
end

selection_model = get_selection_model(grid_view)
connect_signal_selection_changed!(selection_model) do x::SelectionModel, position::Integer, n_items::Integer
    println("selected item is now: $position")
end
set_child!(window, grid_view)
source

Functions that operate on this type:


Separator

Mousetrap.SeparatorType

Separator <: Widget

Simple spacer, fills its allocated area with a solid color.

Constructors

Separator([::Orientation, opacity::AbstractFloat = 1.0])

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


Shader

Mousetrap.ShaderType

Shader <: SignalEmitter

OpenGL shader program, contains a fragment and vertex shader.

See the manual chapter on native rendering for more information.

Constructors

Shader()

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


Shape

Mousetrap.ShapeType

Shape <: SignalEmitter

OpenGL vertex buffer, pre-initialized as one of various shape types.

See the manual chapter on native rendering for more information.

Constructors

Shape()
Point(::Vector2f)
Points(::Vector{Vector2f})
Triangle(::Vector2f, ::Vector2f, ::Vector2f)
Rectangle(top_left::Vecto2f, size::Vector2f)
Circle(center::Vector2f, radius::AbstractFloat, n_outer_vertices::Integer)
Ellipse(center::Vector2f, x_radius::AbstractFloat, y_radius::AbstractFloat, n_outer_vertices)
Line(::Vector2f, ::Vector2f)
Lines(::Vector{Pair{Vector2f, Vector2f}})
LineStrip(::Vector2{Vector2f})
Polygon(::Vector{Vector2f})
RectangularFrame(top_left::Vector2f, outer_size::Vector2f, x_width::AbstractFloat, y_width::AbstractFloat)
CircularRing(center::Vector2f, outer_radius::AbstractFloat, thickness::AbstractFloat, n_outer_vertices::Integer)
EllipticalRing(center::Vector2f, outer_x_radius::AbstractFloat, outer_y_radius::AbstractFloat, x_thickness::AbstractFloat, y_thickness::AbstractFloat, n_outer_vertices::Unsigned)
Wireframe(::Vector{Vector2f})
Outline(other_shape::Shape)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


ShortcutEventController

Mousetrap.ShortcutEventControllerType

ShortcutEventController <: EventController

Triggers actions if their associate shortcuts are recognized. Call add_action! to specify which actions the controller should manage.

Constructors

ShortcutEventController()

Signals

(no unique signals)

Fields

(no public fields)

Example

action = Action("example.action", app)
set_function!(action) do x::Action
    println("example.action activated")
end

add_shortcut!(action, "<Control>space")
# activate action when the user presses Control + Space

shortcut_controller = ShortcutEventController()
add_action!(shortcut_controller, action)

add_controller!(window, shortcut_controller)
source

Functions that operate on this type:


ShortcutTrigger

Mousetrap.ShortcutTriggerType

ShortcutTrigger

String expressing a combination of zero or more modifier keys, enclosed in <>, followed by exactly one non-modifier key.

See the section on ShortctuEventController in the manual chapter on event handling for more information.

Constructors

ShortcutTrigger(::String)

Fields

(no public fields)

source

Functions that operate on this type:


SignalEmitter

Mousetrap.SignalEmitterType

SignalEmitter <: Any

Object that can emit signals.

Any signal emitter is memory-managed independently of Julia, once its internal reference counter reaches zero, it is safely deallocated. Julia users do not have to worry about keeping any signal emitters in scope, it is kept alive automatically.

Supertype

Any

Subtypes

source

SingleClickGesture

Functions that operate on this type:


SpinButton

Mousetrap.SpinButtonType

SpinButton <: Widget

Widget with a value-entry and two buttons.

Constructors

SpinButton(lower::Number, upper::Number, step_increment::Number, [orientation::Orientation])

Signals

value_changed

(::SpinButton, [::Data_t]) -> Nothing

Emitted when the value property of the Adjustment changes.

Fields

(no public fields)

source

Functions that operate on this type:


Spinner

Mousetrap.SpinnerType

Spinner <: Widget

Graphical widget that signifies that a process is busy. Set set_is_spinning! to true to start the spinning animation.

Constructors

Spinner()

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


Stack

Mousetrap.StackType

Stack <: Widget

Selectable widget that always shows exactly one of its children. Use StackSwitcher or StackSidebar to provide a way for users to choose the page of the stack.

Connect to the signals of the SelectionModel provided by get_selection_model to track which stack page is currently selected.

Constructors

Stack()

Signals

(no unique signals)

Fields

(no public fields)

Example

stack = Stack()

add_child!(stack, Label("Page 01"), "Page 01")
add_child!(stack, Label("Page 02"), "Page 02")
add_child!(stack, Label("Page 03"), "Page 03")

stack_switcher = StackSwitcher(stack)

box = Box(ORIENTATION_VERTICAL)
push_back!(box, stack)
push_back!(box, stack_switcher)
set_child!(window, box)
source

Functions that operate on this type:


StackID

Functions that operate on this type:


StackSidebar

Mousetrap.StackSidebarType

StackSidebar <: Widget

Widget that allows users to select a page of a Stack.

Constructors

StackSidebar(::Stack)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


StackSwitcher

Mousetrap.StackSwitcherType

StackSwitcher <: Widget

Widget that allows users to select a page of a Stack.

Constructors

StackSwitcher(::Stack)

Signals

(no unique signals)

Fields

(no public fields)

source

Functions that operate on this type:


StylusEventController

Mousetrap.StylusEventControllerType

StylusEventController <: SingleClickGesture <: EventController

Controller handling events from a stylus devices, such as drawing tablets.

Has access to many manufacturer specific sensors, see the section on StylusEventController in the manual chapter on event handling for more information.

Constructors

StylusEventController()

Signals

stylus_up

(::StylusEventController, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

Emitted once when the stylus seizes to make contact with the touchpad, where x and y is the cursor position, in pixels.

stylus_down

(::StylusEventController, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

Emitted once when the stylus makes contact with the touchpad, where x and y are the cursor position, in pixels.

proximity

(::StylusEventController, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

Emitted when the stylus enters or exits the proximity distance recognized by the touchpad. This will usually precede a stylus_down or stylus_up signal.

motion

(::StylusEventController, x::AbstractFloat, y::AbstractFloat, [::Data_t]) -> Nothing

Emitted once per frame, while the cursor is inside the allocated area of the widget, where x and y are the current cursor position, in pixels.

Fields

(no public fields)

Example

stylus_controller = StylusEventController()
connect_signal_motion!(stylus_controller) do self::StylusEventController, x::AbstractFloat, y::AbstractFloat
    println("stylus position detected at ($x, $y)")
end
add_controller!(window, stylus_controller)
source

Functions that operate on this type:


SwipeEventController

Mousetrap.SwipeEventControllerType

SwipeEventController <: SingleClickGesture <: EventController

Recognizes swipe gestures (touch-only).

Constructors

SwipeEventController()

)

Signals

swipe

(::SwipeEventController, x_velocity::AbstractFloat, y_velocity::AbstractFloat, [::Data_t]) -> Nothing

Emitted once per frame while a swipe gesture is active, where x_velocity and y_velocity are the current velocity of the swipe, in pixels.

Fields

(no public fields)

Example

swipe_controller = SwipeEventController()
connect_signal_swipe!(swipe_controller) do self::SwipeEventController, x_velocity::AbstractFloat, y_velocity::AbstractFloat
    print("swiping ")
    
    if (y_velocity < 0)
        print("up ")
    elseif (y_velocity > 0)
        print("down ")
    end
    
    if (x_velocity < 0)
        println("left")
    elseif (x_velocity > 0)
        println("right")
    end
end
add_controller!(window, swipe_controller)
source

Functions that operate on this type:


Switch

Mousetrap.SwitchType

Switch <: Widget

Widget with a binary state, emits signal switched when triggered.

Constructors

Switch()

Signals

switched

(::Switch, [::Data_t]) -> Nothing

Emitted whenever the internal state of a Switch changes, for example by set_is_active!, or by the user operating the Switch.

Fields

(no public fields)

source

Functions that operate on this type:


TextView

Mousetrap.TextViewType

TextView <: Widget

Multi-line text entry.

Constructors

TextVew()

Signals

text_changed

(::TextView, [::Data_t]) -> Nothing

Emitted when underlying text buffer is modified in any way.

Fields

(no public fields)

Example

text_view = TextView()
set_text!(text_view, "Write here")
connect_signal_text_changed!(text_view) do self::TextView
    println("text is now: $(get_text(self))")
end
source

Functions that operate on this type:


Texture

Mousetrap.TextureType

Texture <: TextureObject <: SignalEmitter

OpenGL Texture.

See the manual chapter on native rendering for more information.

Constructors

Texture()

Signals

(no unique signals)

Fields

(no public fields)

source

TextureObject

Functions that operate on this type:


Time

Mousetrap.TimeType

Time

Object representing a duration of time, nanoseconds precision, may be negative.

Constructors

nanoseconds(::Int64)
microseconds(::Number)
milliseconds(::Number)
seconds(::Number)
minutes(::Number)

Fields

(no public fields)

Example

# convert seconds to microseconds
println(as_microseconds(seconds(3.14159)))
source

Functions that operate on this type:


ToggleButton

Mousetrap.ToggleButtonType

ToggleButton <: Widget

Button with a boolean state. Emits signal toggled when its state changes.

Constructors

ToggleButton()
ToggleButton(label::Widget)
ToggleButton(::Icon)

Signals

toggled

(::ToggleButton, [::Data_t]) -> Nothing

Emitted when the widgets internal state changes from active to inactive, or inactive to active.

clicked

(::ToggleButton, [::Data_t]) -> Nothing

Emitted when the user clicks the widget using a mouse or touchscreen.

Fields

(no public fields)

Example

toggle_button = ToggleButton()
connect_signal_toggled!(toggle_button) do self::ToggleButton
    println("state is now: " get_is_active(self))
end
set_child!(window, toggle_button)
source

Functions that operate on this type:


TransformBin

Mousetrap.TransformBinType

TransformBin <: Widget

Container with a singular child, allows applying spatial transform operations to its child widget.

Constructors

TransformBin()
TransformBin(child::Widget)

Signals

(no unique signals)

Fields

(no public fields)

Example

# continuously rotate a widget

widget = Button()
bin = TransformBin()
set_child!(widget)

animation = Animation(bin, seconds(1))
set_repeat_count!(animation, 0) # infinite repeats
on_tick!(animation, bin) do self::Animation, bin::TransformBin
    rotate!(bin, degrees(1))
end
play!(animation)

set_child!(window, button)
source

Functions that operate on this type:


TypedFunction

Mousetrap.TypedFunctionType

TypedFunction

Object used to invoke an arbitrary function using the given signature. This wrapper will automatically convert any arguments and return values to the types specified as the signature, unless impossible, at which point an assertion error will be thrown on instantiation.

In this way, it can be used to assert a functions signature at compile time.

Constructors

(no public constructors)

Fields

(no public fields)

Example

as_typed = TypedFunction(Int64, (Integer,)) do(x::Integer)
    return string(x)
end
as_typed(12) # returns 12, because "12" will be converted to given return type, Int64
source

Vector2

Mousetrap.Vector2Type

Vector2{T}

Vector with two components, all operations are component-wise, just like in GLSL.

Constructors

Vector2{T}(::T, ::T)
Vector2{T}(both::T)

Fields

  • x::T
  • y::T
source

Vector3

Mousetrap.Vector3Type

Vector3{T}

Vector with 4 components, all operations are component-wise, just like in GLSL.

Constructors

Vector3{T}(::T, ::T, ::T)
Vector3{T}(all::T)

Fields

  • x::T
  • y::T
  • z::T
source

Vector4

Mousetrap.Vector4Type

Vector4{T}

Vector with 4 components, all operations are component-wise, just like in GLSL.

Constructors

Vector4{T}(::T, ::T, ::T, ::T)
Vector4{T}(all::T)

Fields

  • x::T
  • y::T
  • z::T
  • w::T
source

Viewport

Mousetrap.ViewportType

Viewport <: Widget

Container that displays part of its singular child. The allocated size of the Viewport is independent of that of its child.

The user can control which part is shown by operating two scrollbars. These will automatically hide or show themself when the user's cursor enters the viewport. This behavior can be influenced by setting the ScrollbarVisibilityPolicy for one or both of the scrollbars.

Viewport can be forced to obey the width and/or height of its child by setting set_propagate_natural_width! or set_propagate_natural_height! to true.

The placement of both scrollbars at the same time can be set with set_scrollbar_placement!.

Connect to the value_changed signal of each of the scrollbars Adjustment in order to react to the user scrolling the Viewport.

Constructors

Viewport()

Signals

scroll_child

(::Viewport, scroll_type::ScrollType, is_horizontal::Bool, [::Data_t]) -> Nothing

Emitted any time a user triggers a scroll action that moves one or both of the Viewports scroll bars, where scroll_type identifies the type of action that triggered the scrolling, while is_horizontal determines along which axis the scrolling took place.

Fields

(no public fields)

source

Functions that operate on this type:


Widget

Mousetrap.WidgetType

Widget <: SignalEmitter

Superclass of all renderable entities in Mousetrap. Like all SignalEmitters, a widgets lifetime is managed automatically.

Widgets have a large number of properties that influence their size and position on screen. See the manual chapter on widgets for more information.

In order for an object to be treated as a widget, it needs to subtype this abstract type and define Mousetrap.get_top_level_widget. See the manual section on compound widgets in the chapter on widgets.

All widgets share the following signals, where T is the subclass of Widget. For example, signal realize of class Label has the signature (::Label, [::Data_t]) -> Nothing:

Signals

realize

(::T, [::Data_t]) -> Nothing

Emitted when the widget is shown for the first time after being initialized.

unrealize

(::T, [::Data_t]) -> Nothing

Emitted when the widget was hidden and no longer has an allocated area on screen.

destroy

(::T, [::Data_t]) -> Nothing

Emitted when the widgets reference count reaches 0, it will be finalized and deleted permanently.

hide

(::T, [::Data_t]) -> Nothing

Emitted when the widget is hidden, for example by calling hide!, being removed from its parent, or its parent being hidden.

show

(::T, [::Data_t]) -> Nothing

Emitted when the widget is shown, for example by calling show! or its parent being shown.

map

(::T, [::Data_t]) -> Nothing

Emitted when the widget has chosen its final size allocation and is assuming its size and position on screen.

unmap

(::T, [::Data_t]) -> Nothing

Emitted when the widget looses its current size allocation, usually in the process of being hidden or destroyed.

Fields

(no public fields)

Supertype

Any

Subtypes

source

Functions that operate on this type:


Window

Mousetrap.WindowType

Window <: Widget

Top-level window, associated with an Application. Has exactly one child, as well as a titlebar widget, which will usually be a HeaderBar.

When the users window manager requests for a window to close, signal close_request will be emitted, whose return value can prevent the window from closing.

Constructors

Window(app::Application)

Signals

close_request

(::Window, [::Data_t]) -> WindowCloseRequestResult

Emitted when the window is requested to be closed, for example by the user pressing the close button. Depending on whether the return value of the signal handler is WINDOW_CLOSE_REQUEST_RESULT_ALLOW_CLOSE or WINDOW_CLOSE_REQUEST_RESULT_PREVENT_CLOSE, closing of the window will be permitted or prevented.

activate_default_widget

(::Window, [::Data_t]) -> Nothing

Emitted when the child widget designated via set_default_widget! was activated.

activate_focused_widget

(::Window, [::Data_t]) -> Nothing

Emitted when the child widget that currently holds input focus is activated.

Fields

(no public fields)

Example

main() do app::Application
    window = Window(app)
    present!(window)
end
source

Functions that operate on this type: