pod::Prima::Widget(3)
okay bestie, this is pod::Prima::Widget(3) from User Contributed Perl Documentation โ the window-management manual, and it's genuinely iconic ๐
๐ธ NAME ๐ธ
Prima::Widget โ window management, no cap.
โจ SYNOPSIS โจ
# create a widget
my $widget = Prima::Widget-> new(
size => [ 200, 200],
color => cl::Green,
visible => 0,
onPaint => sub {
my ($self,$canvas) = @_;
$canvas-> clear;
$canvas-> text_out( "Hello world!", 10, 10);
},
);
# manipulate the widget
$widget-> origin( 10, 10);
$widget-> show;
๐ฆ DESCRIPTION ๐ฆ
Prima::Widget is a descendant of the Prima::Component class, and it provides comprehensive management of system-dependent windows. Objects of the Prima::Widget class are mapped to the screen space as a rectangular area, with distinct boundaries, a pointer and sometimes a cursor, and a user-selectable input focus. It's giving "whole window system, but make it a Perl object" โจ
๐ USAGE ๐
The Prima::Widget class and its descendants are used widely throughout the toolkit and are at the center of almost all its user interaction and input-output functions. The notification system, explained in Prima::Object, is heavily used in the Prima::Widget class, providing the programmer with unified access to the system-generated events that occur when for example the user moves a window, clicks the mouse, types on the keyboard, etc. Literally the main character energy of the toolkit ๐ซถ
๐ ๏ธ Creation and destruction ๐ ๏ธ
The widget creation syntax is the same as for creating other Prima objects:
Prima::Widget-> new(
name => 'Widget',
size => [ 20, 10],
onMouseClick => sub { print "click\n"; },
owner => $owner,
);
A widget must almost always be explicitly assigned an owner. The owner object is either a Prima::Widget descendant, in which case the widget is drawn inside its inferior, or the application object so that the widget becomes a top-level screen object. This is the reason why the insert syntax is preferred, as it is more illustrative and is more convenient for creating several widgets in one call ( see Prima::Object ). Slay a whole batch of widgets in one go ๐
$owner-> insert( 'Prima::Widget',
name => 'Widget',
size => [ 20, 10],
onMouseClick => sub { print "click\n"; },
);
These two examples produce identical results. fr fr.
As a descendant of the Prima::Component class, Prima::Widget objects also send the Create notification while being created ( more precisely, after its init stage is finished. See Prima::Object for details). This notification is called and processed within the new() method. Another notification Setup is sent after the widget finishes the creation process. This message is posted though, i.e. it is invoked within the new() method but is processed inside the application event loop. This means that the moment when the Setup event is executed is uncertain, as it is with all posted messages. Its delivery is system-dependent, so its use must be considered with care. lowkey important, bestie โ ๏ธ
After the widget is created, it is usually asked to render its visual content by the system, provided that the widget is visible. This request is delivered by the Paint notification.
When the lifetime of the widget is over, its method destroy() should be called. In some circumstances, the method can be also called implicitly by the toolkit. If the widget gets destroyed because its owner also gets destroyed, it is guaranteed that its widget children will be destroyed first, and the owner only afterward. In such situation the widget can still operate but with limited functionality ( see Prima::Object, the Creation section ). order matters, and the toolkit is handling it ๐
๐จ Graphic content ๐จ
There are two ways graphics can be displayed in a widget. The first is the event-driven method when the Paint notification arrives, notifying the widget that it must re-paint itself. The second is the 'direct' method when the program itself begins drawing on the widget. Two paths, same screen, pick your vibe ๐
โจ Event-driven rendering โจ
When the system decides that a widget needs to update its graphics it sends the Paint notification to the program. The notification has a single ( besides the widget itself ) parameter, referred to as canvas, the object where the drawing is performed. During the event-driven call initiated by the system, it is always the widget itself. Other callers of the Paint notification though can provide another object to draw on:
$widget-> notify('Paint', $some_other_widget);
When programming this notification use this parameter, not the widget itself, for the painting. this is the assignment, bestie ๐ซถ
An example of the Paint notification handler could be a simple one like this:
Prima::Widget-> new(
...
onPaint => sub {
my ( $self, $canvas) = @_;
$canvas-> clear;
$canvas-> text_out("Clicked $self->{clicked} times", 10, 10);
},
onMouseClick => sub {
$_[0]-> {clicked}++;
$_[0]-> repaint;
},
);
The example shows several important features of the event-driven mechanism. First, no begin_paint()/end_paint() brackets are used within the callback - these are called implicitly. Second, when the widget graphics need to be changed (after a mouse click, for example), no code like notify(q(Paint)) is needed - the repaint() method is used instead. Note that the execution of Paint callbacks may or may not occur inside the repaint() call. This behavior is managed by the ::syncPaint property. A call to repaint() marks the whole widget's area to be refreshed, or invalidates the area. For the finer access to the area that should be repainted, the functions invalidate_rect() and validate_rect() are used. Thus the call
$x-> repaint()
is identical to the
$x-> invalidate_rect( 0, 0, $x-> size);
call. same energy, different spelling โจ
The area passed to the invalidate_rect() method will be accessible as the clipping rectangle inside the Paint notification. However, the interaction between the program logic and the system logic can result in situations where the system may request repainting of the other parts of the widget, not only those that were requested by the invalidate_rect call. This can happen for example when windows from another program move over the widget. In these cases, the clipping rectangle might not be exactly the same. Moreover, the clipping rectangle can even become empty as a result of these interactions, and the notification won't be called at all. not me getting an empty clip rect ๐ญ
The clipping rectangle is represented differently inside and outside the drawing mode. To access the rectangle, the ::clipRect property is used. Inside the Paint call (or, strictly speaking, inside the begin_paint/end_paint brackets) the rectangle is measured in the inclusive-inclusive coordinates, whereas the invalidate_rect(), validate_rect(), and get_invalid_rect() method use the inclusive-exclusive coordinates. Assuming the clipping rectangle is not changed by the system, the example below illustrates the difference:
$x-> onPaint( sub {
my @c = $_[0]-> clipRect;
print "clip rect:@c\n";
});
$x-> invalidate_rect( 10, 10, 20, 20);
...
clip rect: 10 10 19 19
The notification handler can use the ::clipRect property to optimize the painting code, drawing only the parts that are necessary to draw. draw less, slay more ๐
In the drawing mode it is possible to change the ::clipRect property, however, increasing the clipping rectangle in such a way won't make it possible to draw on the screen area that lies outside the original clipping region. This is part of the same mechanism that doesn't allow drawing outside the widget's geometric boundaries. boundaries are boundaries, bestie ๐ง
๐๏ธ Direct rendering ๐๏ธ
The direct rendering, contrary to the event-driven, is initiated by the program, not by the system. If a programmer wishes to paint over a widget immediately, then the begin_paint() method should be called first, and, if it is successful, the part of the screen occupied by the widget is accessible for drawing.
This method is useful, for example, for graphic demonstration programs, that draw continuously without any input. Another use of this method is the drawing directly on the screen, which is performed by entering the drawing mode on the $::application object, that does not have the Paint notification. The application's graphic canvas represents the whole screen, allowing drawing the windows that also belong to other programs. whole screen canvas? main character behavior ๐
The majority of the widget rendering code is using the event-driven drawing. Sometimes, however, the changes needed to be made to the widget's graphic context are so insignificant, so the direct rendering method is preferable, because of the cleaner and terser code. Below is an example of a simple progress bar that draws a simple colored stripe. The event-driven code would be ( in short, omitting many details ) like this:
$bar = Widget-> new(
width => 100,
onPaint => sub {
my ( $self, $canvas) = @_;
$canvas-> color( cl::Blue);
$canvas-> bar( 0, 0, $self-> {progress}, $self-> height);
$canvas-> color( cl::Back);
$canvas-> bar( $self-> {progress}, 0, $self-> size);
},
);
...
$bar-> {progress} += 10;
$bar-> repaint;
# or, more efficiently,
# $bar-> invalidate_rect( $bar->{progress}-10, 0,
# $bar->{progress}, $bar-> height);
While the version with the direct drawing would be
$bar = Widget-> new( width => 100 );
...
$bar-> begin_paint;
$bar-> color( cl::Blue);
$bar-> bar( $progress, 0, $progress + 10, $bar-> height);
$bar-> end_paint;
$progress += 10;
The pros and the contras are obvious: the event-driven rendered widget correctly represents the status after an eventual repaint, for example when the user sweeps a window over the progress bar widget. The direct method is not that smart, but if the status bar is an insignificant part of the program it can be used instead. choose your fighter ๐
Both methods can be effectively disabled by using the locking mechanism. The lock() and unlock() methods can be called several times, counting the requests. This feature is useful because many properties implicitly call repaint(), and if several of these properties are called in a row or within each other, the unnecessary redrawing of the widget can be avoided by wrapping such calls in the lock/unlock brackets. The drawback is that the last unlock() call triggers the repaint() method unconditionally. last unlock said "and I took that personally" ๐๐
๐ Geometry ๐
Okay bestie, geometry time โ and no cap, this part is lowkey the whole vibe of how widgets sit and slay on screen. โจ
๐ Basic properties ๐
A widget always has its position and size determined, even when it is not visible on the screen. Prima::Widget provides several properties with overlapping functionality that manage the geometry of widgets.
The base properties are ::origin and ::size, and the derived ones are ::left, ::bottom, ::right, ::top, ::width, ::height, and ::rect. ::origin and ::size operate on two integers, ::rect on four, and the others on one integer value.
The Prima toolkit coordinate space begins in the lower bottom corner, so the combination of ::left and ::bottom is the same as ::origin, and the combination of ::left, ::bottom, ::right and ::top is the same as the ::rect property.
When widgets are moved or resized, two notifications may occur, correspondingly, Move and Size. The parameters for both are the old and the new position and size. The notifications occur irrespective of whether the geometry change was issued by the program itself or by the user.
๐ธ Implicit size regulations ๐ธ
There exist two other properties that regulate widget size, ::sizeMin and ::sizeMax. They keep the minimum and the maximum sizes the widget may have. A call that would try to assign the widget size outside the ::sizeMin and ::sizeMax limits will fail; the widget size will always be adjusted to the limits' values.
Changes to the widget's position and size can also occur automatically if the widget's owner changes its size. The toolkit contains several implicit rules that define how exactly these changes should occur. For example, the ::growMode property accepts a set of gm::XXX flags that encode this behavior. The exact meaning of the gm::XXX flags is not given here (see the description to ::growMode in the API section), but in short, it is possible using fairly simple means to program changes to widget size and position when its owner is resized. By default, the value of the ::growMode property is 0, so widgets don't change either their size or position on these occasions. A widget with ::growMode set to 0 stays always in the left bottom corner of its owner. When, for example, a widget is expected to stay in the right bottom corner, or the left top corner, the gm::GrowLoX and gm::GrowLoY values must be used, correspondingly. If a widget is expected to cover its owner's lower part and change its width following the owner's, (a horizontal scroll bar in an editor window is a good example of this behavior), the gm::GrowHiX value must be used.
When such implicit size change occurs, the ::sizeMin and ::sizeMax properties still play their part โ they still do not allow the widget's size to exceed these limits. However, this algorithm has a problem, that is illustrated by the following example. Imagine a widget with the size-dependent ::growMode set to gm::GrowHiX, which means that the increase or decrease of the owner width would result in a similar change in the widget. If the implicit width change would match verbatim the change of the owner's width, then the widget's size (and probably its position) will be incorrect after an attempt is made to change the widget's size to values outside the size limits.
Here's the example: let's assume that the child widget has width of a 100 pixels, its growMode property is set to gm::GrowHiX, and its sizeMin property is set to (95, 95). The widget's owner has a width of 200 pixels. If the owner widget changes its width from 200 to 195 and then to 190 pixels, and then back again, then one naively could expect that the child widget's width would undergo the following changes:
Owner Child
Initial state 200 100
Shrink 195 -5 95
Shrink 190 -5 95 - as it can not be less than 95.
Grow 195 +5 100
Grow 200 +5 105
The situation here is fixed by introducing the virtual size. The ::size property is derived from the virtual size, but while ::size cannot exceed the size limits, the virtual size can. Moreover, it can even accept negative values. This algorithm produces the correct sizes:
Owner Child's Child's
virtual width width
Initial state 200 100 100
Shrink 195 -5 95 95
Shrink 190 -5 90 95
Grow 195 +5 95 95
Grow 200 +5 100 100
๐ฆ Geometry managers ๐ฆ
The concept of geometry managers is imported from the Tk, which in turn is a port of the Tcl-Tk. The idea behind it is that the widget size and position are governed by one of the managers, and each manager has its own set of properties. One can select the manager by assigning the ::geometry property one of the gt::XXX constants. The native (and the default) geometry manager is the described above grow-mode algorithm (gt::GrowMode). The currently implemented Tk managers are packer (gt::Pack) and placer (gt::Place). Each has its own set of options and methods, and their manuals are provided separately in Prima::Widget::pack and Prima::Widget::place (the manpages are also imported from the Tk).
Another concept that comes along with geometry managers is the 'geometry request size'. It is realized as a two-integer property ::geomSize, which reflects the size deduced by some intrinsic widget knowledge. The idea is that ::geomSize is merely a request to a geometry manager, whereas the latter changes ::size accordingly. For example, a button might set its 'intrinsic' width in accord with the width of the text string displayed in it. If the default width for such a button is not overridden, it is assigned with such a width. By default, under the gt::GrowMode geometry manager, setting ::geomSize (and its two semi-alias properties ::geomWidth and ::geomHeight) also changes the actual widget size. Moreover, when the size is passed to the Widget initialization code, the ::size property is used to initialize ::geomSize. Such design minimizes the confusion between the two properties, and also minimizes the direct usage of ::geomSize, limiting it to selecting the advisory size in the internal code.
The geometry request size is useless under the gt::GrowMode geometry manager, but Tk managers use it extensively.
๐ Relative coordinates ๐
Another geometry issue, or rather a programming technique, must be mentioned โ the relative coordinates. It is a well-known problem, when a dialog window, developed with one font, looks garbled on another system with another font. The relative coordinates technique solves this problem by introducing the ::designScale two-integer property, the width and height of the font that was used when the dialog window was designed. With this property supplied, the position and size supplied when the widget is created on another setup using another font, are adjusted proportionally to the actual font metrics.
The relative coordinates can only be used when passing the geometry properties values, and only before the creation stage, before the widget is created. This is because the scaling calculations are made in the Prima::Widget::profile_check_in() method.
To use the relative coordinates technique the owner (or the dialog) widget must set its ::designScale property to the font metrics, and the ::scaleChildren property to 1. Widgets created with an owner that meets these requirements automatically participate in the relative coordinates scheme. If a widget must be excluded from the relative geometry applications, either the owner's property ::scaleChildren must be set to 0, or the widget's ::designScale must be set to undef. As the default ::designScale value is undef, no implicit relative geometry schemes are applied by default.
The ::designScale property is automatically propagated to the children widgets, unless the explicit ::designScale overrides it. This is useful when a child widget is a complex widget container, and was designed on yet another setup with different font sizes.
Note: it is advised to test your applications with thePrima::Stressmodule that assigns a random font as the default. SeePrima::Stressfor more.
๐ Z-order ๐
When two widgets overlap on the screen, one of these is drawn in full whereas the other only partly. Prima::Widget provides management of the Z-axis ordering, with these four methods: first(), last(), next(), and prev(). The methods return, correspondingly, the first and the last widgets in the Z-order stack, and the direct neighbors of the widget ($widget-> next-> prev always is the $widget itself given that $widget-> next exists). If a widget is last that means that it is not obscured by its sibling widgets, i e the topmost one. ๐
The Z-order can also be changed at runtime (but not during the widget's creation). Three methods that change the Z-order:
bring_to_front()โ sends the widget to the top of the stack.send_to_back()โ sends it to the bottom.insert_behind()โ sets a widget behind another widget.
Changes to Z-order trigger the ZOrderChanged notification. ๐
๐ Parent-child relationship ๐
okay so by default, if a widget is the child of another widget or a window, it gets clipped by its ownerโs boundaries and it moves together with its owner when the owner changes position. In this setup, the childโs owner is also its parent. ๐
A widget must always have an owner, but not necessarily a parent. The ::clipOwner property is 1 by default; set it to 0 and the widget switches into parent-less mode. That means it is neither clipped nor moved together with its parent. The widget becomes parent-less, or, more strictly speaking, the screen becomes its parent. Also, in this mode, the widgetโs origin offset is calculated not from the ownerโs coordinates but from the screen, and clicking on the widget does not bring its ownerโs top-level window to the front. โจ
You can get the same result if a widget is inserted in the application object that does not have any screen visualization. A widget that belongs to the application object has its ::clipOwner value set to 0, and it cannot be changed. ๐ซถ
The ::clipOwner property opens up the possibility for toolkit widgets to live inside other programsโ windows. The ::parentHandle property can be assigned a valid system window handle, so the widget becomes a child of this window. This option has a caveat, because normal widgets are never destroyed for no reason, and likewise, top-level windows are never destroyed before their Close notification agrees to their destruction. When a widget is inserted into another application it must be prepared to be destroyed at any moment. It is recommended to use prior knowledge about such an application, and, even better, use one or another inter-process communication scheme to interact with it.
bestie, this is the โliving in someone elseโs windowโ situation โ cute in theory, but you gotta be ready for it to vanish at any moment ๐ญ
A widget doesnโt need to do any special action to become an โowner.โ A widget that was referred to in the ::owner property of another widget becomes an owner of the latter automatically. The get_widgets() method returns the list of these children widgets, similar to the Prima::Component::get_components() method, but it returns only Prima::Widget descendant objects. ๐
Widgets can change their owner at any moment. The ::owner property is both readable and writable, and if a widget is visible during the owner change, it immediately appears under different coordinates and different clipping conditions after the property change, given that its ::clipOwner property is set to 1. ๐ฅ
๐ Visibility ๐
Widgets are created visible by default. The visibility status is managed by the ::visible property, and its two convenience alias methods, show() and hide(). ๐ธ
When a widget gets hidden, its geometry is not discarded; the widget retains its position and size and is still subject to all previously discussed implicit sizing issues. When the change to the ::visible property is made, the screen is not updated immediately but in the next event loop invocation, because uncovering the underlying area of a hidden widget, and repainting a newly-shown widget, both depend on the event-driven rendering functionality. If the graphic content must be updated immediately, the update_view() method must be called โ but thereโs a caveat. It is obvious that if a widget is shown, the only content to be updated is its own. When a widget becomes invisible, it may uncover more than one underlying widget, and even if the uncovered widgets belong to the same program, it is unclear what widgets must be updated and when. For practical reasons, it is enough to get one event loop passed, by calling the yield() method on the $::application object. The other notifications may pass here as well, however. ๐ฆ
There are other kinds of visibility. A widget might be visible, but one of its owners might not. Or, a widget and its owners might be visible, but they might be overshadowed by other windows. These conditions are returned by showing() and exposed() functions, correspondingly. So, if a widget is โexposed,โ it is โshowingโ and โvisibleโ; the exposed() method always returns 0 if the widget is either not โshowingโ or not โvisible.โ If a widget is โshowing,โ then it is always โvisible.โ showing() always returns 0 if a widget is invisible. โจ
Change to the visibility status triggers the Hide and Show notifications. ๐
๐ฏ Focus ๐ฏ
One of the key points of any GUI system is that only one window at a time can possess focus. The widget is focused if the keyboard input is directed to it. ๐
Prima::Widget property ::focused manages the focused state of the widget. It is often too powerful to be used directly, however. Its wrappers, the ::selected and the ::current properties, are usually more convenient to operate. ๐
The ::selected property sets focus to a widget only if it is allowed to be focused, by consulting with the value of the ::selectable property. When the widget is selectable, the focus may be passed to either the widget itself or to one of its ( grand-) children. For example, when โselectingโ a window with a text field by clicking on a window, one does not expect the window itself to be focused, but the text field. To achieve this and reduce unnecessary coding, the ::current property is introduced. The โcurrentโ widget gets precedence in getting selected over widgets that are not โcurrent.โ ๐
De-selecting, in turn, leaves the system in such a state when no window has input focus. There are two convenience shortcuts select() and deselect() defined, aliased to selected(1) and selected(0), correspondingly. ๐ซถ
Within the whole GUI space, there can be only one focused widget, and in the same fashion there can be only one current widget for each owner widget. A widget can be marked as current by calling either its ::current property or the owner widgetโs ::currentWidget property. When a widget gets focused, the reassignments of the current widgets happen automatically. The reverse is also true: if a widget becomes current while it belongs to the widget tree with the focus in one of its widgets, then the focus is automatically passed to it, or down to its hierarchy if the widget itself is not selectable. ๐ฅ
These relations between the current widget pointer and focus allow the toolkit to implement the focusing hierarchy easily. The focused widget is always on the top of the chain of its owner widgets, where each is the current widget. If, for example, a window that contains a widget that contains a focused button becomes un-focused, and then the user selects the window again, then the button will become focused automatically. iconic behavior, honestly ๐
Changes to the focus produce the Enter and Leave notifications. โจ
The next section discusses the mouse- and keyboard-driven focusing schemes. Note that all of these work via the ::selected property, and do not allow to focus the widgets with their ::selectable property set to 0.
๐ฑ๏ธ Mouse-aided focusing ๐ฑ๏ธ
Typically when the user clicks the left mouse button on a widget, the latter becomes focused. One can note that not all widgets become focused after the mouse click โ scroll bars, for example. Another behavior is the one described above with the window and the text field: clicking the mouse on the window focuses the text field, not the window. ๐ญ
Prima::Widget has also the ::selectingButtons property, a combination of the mb::XXX ( mouse buttons ) flags. If the bits corresponding to the buttons are present there, then the click of this mouse button will automatically call ::selected(1) on the widget that received the mouse click. โญ
Another boolean property ::firstClick determines the behavior when the mouse button action is about to focus a widget, but the widgetโs top-level window is not active. The default value of ::firstClick is 1, but if it is set otherwise, the user must click twice on the widget to get it focused. The property does not influence anything if the top-level window was already active when the click event occurred. ๐
Due to different GUI designs, it is hardly possible to force the selection of a top-level window when the user clicked another window. The window manager or the OS can interfere, although this does not always happen, and the results may be different depending on the system. Since the primary goal of the toolkit is portability, such functionality must be considered with care. Moreover, when the user selects a window by clicking not on the toolkit-created widgets, but on the top-level window decorations, it is not possible to discern the case from any other kind of focusing. ๐
โจ๏ธ Keyboard focusing โจ๏ธ
Prima has a built-in way to navigate between the widgets using the tab and arrow keys. The tab ( and its reverse, shift-tab ) key combinations move the focus between the widgets in the same top-level group ( but not inside the same owner widget group ). The arrow keys, if the focused widget is not interested in these keystrokes, move the focus in the specified direction, if it is possible. The methods that calculate the widget to be focused depending on the keystroke are next_tab() and next_positional() ( see API for the details ). โจ๏ธโจ
The next_positional() method uses the geometry of the widgets to calculate which widget is the best candidate when the user presses an arrow key. The next_tab() method uses the ::tabStop and ::tabOrder properties for this. The boolean property ::tabStop is set to 1 by default and is used to check whether the widget is willing to participate in the tab-aided focus circulation or not. If it doesnโt, next_tab() never returns that widget as a candidate to be selected. The value of the ::tabOrder property value is an integer that is unique within the sibling widgets ( i e those that share the same owner ) list. That integer value is used as a simple tag when the next tab-focus candidate is considered. The default ::tabOrder value is -1, which changes to a unique value automatically after the widget creation. ๐
๐ซถ User input ๐ซถ
The toolkit responds to the two basic means of user input โ the keyboard and the mouse. Below are the three aspects of the input handling โ the event-driven, the polling, and the simulated input. ๐ฎโจ
Okay so the event-driven input is the more-or-less natural way of communicating with the user, bestie. When the user presses a key or moves the mouse, a system event occurs and triggers the notification in one or more widgets. Polling gives you the immediate state of the input devices. Itโs rarely chosen, mostly because its usability is limited, and because the info it provides gets passed to the notification callbacks anyway. Simulated input is literally a little more than a notify() call with specifically crafted parameters. It interacts with the system by sending the event through the system API, so input emulation can be more similar to real user actions. The simulated input functions let notifications be called right away, or be post'ed, delaying the notification until the next invocation of the event loop.
โจ๏ธ Keyboard โจ๏ธ
โจ Event-driven โจ
Keyboard input generates several notifications, and the main characters are KeyDown and KeyUp โ no cap. Both have almost the same list of parameters (see the API) containing the keycode, the modifier keys (if any) that were pressed, and an eventual character code. The algorithms that extract the meaning of the key โ like discerning between character keys and functional keys, etc. โ are not described here. The reader is advised to look at the Prima::KeySelector module, which provides some convenience functions for various transformations of the keyboard input values. And also at the Prima::Edit and Prima::InputLine modules, the classes that use keyboard input extensively.
But in short: the keycode is one of the kb::XXX constants (like kb::F10, kb::Esc), and the key modifier value is a combination of the km::XXX constants (km::Ctrl, km::Shift). The notable exception is the kb::None constant, which hints that there is a character code present in the event. Some other kb::XXX-marked keys have a character code as well, and it is up to the programmer to decide how to treat these combinations. It is advised, however, to look at the keycode first, and then at the character code later, to decide what type of key combination the user pressed.
The KeyDown event also has the repeat integer parameter that shows the count of how many times the key was repeatedly pressed. Usually it is set to 1, but if a widget is not able to get its portion of events between the key presses, its value can be higher. If the code doesnโt check for this parameter, some keyboard input may be lost. If introducing the repeat value makes the code too complicated, you may consider setting the ::briefKeys property to 0. ::briefKeys is a boolean property and is 1 by default. If it is set to 0, it guarantees that the repeat value will always be 1, but that comes at the price of certain under-optimization. If the core KeyDown processing code sees a repeat value greater than 1, it simply calls the notification again.
Along with these two notifications, the TranslateAccel event is generated after KeyDown, if the focused widget is not interested in the key event. Its usage covers the eventual needs of the other widgets to read user input, even while being out of focus. A notable example is a button with a hotkey that reacts on the key press when the focus is elsewhere within its top-level window. TranslateAccel has the same parameters as KeyDown, except the REPEAT parameter.
Such an out-of-focus input scheme is also used when Prima checks if a keypress event should trigger a menu item, because the menu items API allows you to declare hotkeys in the Menu definitions. So if a descendant of the Prima::AbstractMenu class is in the widgetโs children tree hierarchy, Prima checks whether it contains some hotkeys that match the user input. See Prima::Menu for the details. In particular, Prima::Widget has the ::accelTable property โ a mere slot for an object that contains a table of hotkeys mapped to custom subroutines.
๐ Polling ๐
The keyboard can only be polled for the states of the modifier keys. The get_shift_state() method returns the state of the modifier keys as a combination of the km::XXX constants.
๐ฎ Simulated input ๐ฎ
There are two methods, key_up() and key_down(), that generate simulated keyboard input. They accept the same parameters as the KeyUp and KeyDown notifications plus the POST boolean flag. See API for details. These methods are convenience wrappers for the key_event() method, which is never used directly.
๐ญ Mouse ๐ญ
โจ Event-driven โจ
The mouse notifications are sent when the user moves the mouse, presses the mouse buttons, or releases them. The notifications are grouped in two sets, after their function. The first set consists of the MouseDown, MouseUp, MouseClick, and MouseWheel notifications, and the second of MouseMove, MouseEnter, and MouseLeave.
The notifications from the first set respond to mouse button actions. Pressing, de-pressing, clicking (and double-clicking), and turning the mouse wheel โ all these actions result in the generation of the four notifications from the group. The notifications are sent together with the mouse pointer coordinates, the button that the user was operating on, and the eventual modifier keys that were pressed, if any. In addition, the MouseClick notification provides an integer parameter of how many clicks occurred on the same button; that one can distinguish between single, double, triple, etc. mouse clicks. The MouseWheel notification provides the numeric argument that reflects how far the mouse wheel was turned. All of these notifications occur when the user operates the mouse while the mouse pointer is within the geometrical bounds of a widget. If the widget is in the capture mode, then these events are sent to it even if the mouse pointer is outside the widgetโs boundaries, and are not sent to the widgets and windows that reside under the mouse pointer.
The second set of notifications responds to mouse pointer movements. When the pointer passes over a widget, it receives first the MouseEnter event, then a series of MouseMove events, and finally the MouseLeave event. The MouseMove and MouseEnter notifications provide the X,Y-coordinates and the eventual modifier keys; MouseLeave provides no parameters.
๐ Polling ๐
The get_mouse_state() method returns a combination of the mb::XXX constants. The ::pointerPos two-integer property reflects the current position of the mouse pointer.
๐ฎ Simulated input ๐ฎ
There are five methods โ mouse_up(), mouse_down(), mouse_click(), mouse_wheel(), and mouse_move() โ that accept the same parameters as their event counterparts do, plus the POST boolean flag. See API for details.
These methods are convenience wrappers for the mouse_event() method, which is never used directly.
๐ซถ Drag and drop ๐ซถ
Widgets can participate in drag-and-drop sessions, interacting with other applications as well as with themselves, with very few restrictions. See below for how to use this functionality.
๐พ Data exchange ๐พ
Prima defines a special clipboard object that serves as an exchange agent whenever data is to be either sent or received in a DND session. To either offer to or choose from many formats that another DND client can work with, use this clipboard (see more in Prima::Clipboard). The DND clipboard can be accessed at any time by calling the $::application->get_dnd_clipboard method.
To successfully exchange data with other applications, you should investigate the results of a $clipboard-> get_formats(1) call to see what types of data the selected application can send or accept. Programs can often exchange text and images in the system-dependent format, and other data in the formats named after the MIME type of the data. For example, Prima supports image formats like image/bmp out of the box, and text/plain on X11, which are selected automatically when operating with pseudo-formats Text or Image. Other MIME formats like f.ex. text/html are not known to Prima, but can be exchanged quite easily; the program only needs to register these formats by calling the Clipboard::register_format method at the start of the program.
๐ฑ๏ธ Dragging ๐ฑ๏ธ
To begin a dragging session, first fill the DND clipboard with data to be exchanged, using one or more formats, then call the start_dnd method. Alternatively, call begin_drag, a wrapper method that can set up the necessary clipboard data itself. See the documentation on these methods for more details.
During the dragging, the sender will receive the DragQuery and DragResponse events, to decide whether the drag session must continue or stop depending on the user interactions, and reflect that decision to the user. Traditionally, mouse pointers are changed to show whether an application will receive dropped data, and if yes, what action (copy, move, or link) it will recognize. Prima will try its best to either use system pointers or synthesize ones that are informative enough; if that is not sufficient, one may present their own pointer schema (see f.ex. how begin_drag is implemented).
๐ฅ Dropping ๐ฅ
To register a widget as a drop target, set its dndAware property to either 1, to mark that it will answer to every format, or to a string, in which case drop events will only be delivered if the DND clipboard contains a format with that string as its name.
When the user initiates a DND session and moves the mouse pointer over the widget, it receives the related events: first a DragBegin event, then a series of DragOver events, and finally a DragEnd event with a flag telling whether the user chose to drop the data to the widget or cancel the session.
okay so the DragOver and DragEnd callbacks are literally your chance to either allow or deny data and select an action (if thereโs more than one allowed by the other application) to proceed with. To do that, set appropriate values in the {allow} and {action} fields of the last hashref parameter that is sent to these event handlers. Also, your program can respond to DragOver by setting the {pad} rectangle โ that caches the last answer and tells the system to not send repeated events with the same input while the mouse pointer stays in the rectangle. ๐
๐ฆ Portability ๐ฆ
X11 and Win32 are rather identical in how they handle DND sessions from the user perspective. The only difference that is significant to Prima here is whether the sender or the receiver is responsible for selecting an action for the available list of actions when the user presses the modifier keys, like CTRL or SHIFT.
On X11, it is the sender that controls that aspect, and tells the receiver what action at any given moment the user chose, by responding to a DragQuery event. On Win32, it is the receiver that selects an action from the list on each DragOver event, depending on the modifier keys pressed by the user; Win32 recommends adhering to the standard scheme where the CTRL key means the dnd::Move action, and the SHIFT key the dnd::Link action, but that is up to the receiver. โจ
Thus, to write a robust and portable program, assume that it may control the actions both as the sender and as the receiver. The toolkitโs system-dependent code will make sure that there will be no ambiguities in the input. F.ex. the sender on Win32 will never be presented with combination of several dnd:: constants inside a DragQuery event, and the X11 receiver will similarly never be presented with such combination inside DragOver. Nevertheless, a portable program must be prepared to select and return a DND action in either callback. ๐
Additionally, the X11 DND protocol describes the situation when the receiver is presented with the choice of actions, and may also ask the user what action to select, or cancel the session altogether. This is okay and is expected by the user, and it is up to your program to use that possibility or not. ๐ซถ
๐จ Colors ๐จ
Prima::Widget extends the functionality of ::color and ::backColor, the properties inherited from the Prima::Drawable class. Their values are the widgetโs foreground and background colors, in addition to their function as template values. Moreover, their dynamic change induces the repainting of the widget. ๐ฅ
The values of these properties can be inherited from the owner; the inheritance is managed by the properties ::ownerColor and ::ownerBackColor. If these are set to 1 then changes to the ownerโs properties ::color or ::backColor are copied automatically to the widget. Once the widgetโs ::color or ::backColor is explicitly set, the owner link breaks automatically by setting ::ownerColor or ::ownerBackColor to 0.
In addition to these two existing color properties, Prima::Widget introduces six others. These are: ::disabledColor, ::disabledBackColor, ::hiliteColor, ::hiliteBackColor, ::light3DColor, and ::dark3DColor. The disabled color pair contains the values that are expected to be used as the foreground and the background when the widget is in the disabled state (see API, ::enabled property). The hilite values serve as colors painting a selection inside of the widget. Selection may be of any kind, and some widgets do not provide any. But for those that do, the hilite color values provide distinct alternative colors. The examples are the selections in the text widgets or the list boxes. The last pair, ::light3DColor and ::dark3DColor is used for drawing 3D-bevelled outlines on the widget. The purpose of all these properties is to respect the system colors and draw the Prima GUI as close as possible to the native system look. ๐
There are eight additional cl:: constants that can be used to access these system colors. These named correspondingly, cl::NormalText, cl::Normal, cl::HiliteText, cl::Hilite, cl::DisabledText, cl::Disabled, cl::Light3DColor, and cl::Dark3DColor. The cl::NormalText constant is an alias to cl::Fore, and cl::Normal - to the cl::Back constant. Another constant set, ci:: can be used with the ::colorIndex property, a multiplexer method for all the eight color properties. ci:: constants mimic their non-RGB cl:: counterparts, so that a call to hiliteBackColor(cl::Red) is equal to colorIndex(ci::Hilite, cl::Red).
The map_color translates these special constants to the 24-bit RGB integer values. The cl:: constants alone are sufficient for acquiring the default values, but the toolkit provides even wider functionality to address default colors for different types of widgets. The cl:: constants can be combined with the wc:: constants, that represent the standard widget classes. If the color property was assigned with a cl:: constant not combined with a wc:: constant, the widget class value is read from the ::widgetClass property. Thus a call to, for example, backColor( cl::Back) on a button and an input line may result in different colors because the cl::Back is translated in the first case to cl::Back|wc::Button, and in another to cl::Back|wc::InputLine. The wc:: constants are described in API. ๐
Dynamic changes of the color properties result in the ColorChanged notification. ๐ซ
๐ Fonts ๐
The default font can be automatically inherited from the owner if the ::ownerFont property is set to 1. If it is set to 0, then the font returned by the get_default_font method is used instead. The method may return different fonts depending on the widget class, name, and user preferences (see Additional resources). ๐
A similar method get_default_popup_font is used to query the default popup font and the ::popupFont property for accessing it. The Prima::Window class has also similar functions, the get_default_menu_font method and the ::menuFont property. ๐ฆ
Dynamic changes to the font property result in the FontChanged notification. ๐
โจ Additional resources โจ
Okay so the resources that Prima::Widget totally operates but that arenโt, like, strictly bound to the widget concept all get gathered here. This section gives you the lowdown on pointer, cursor, hint, menus, and user-specified resources. Bestie, itโs giving โmisc but iconic.โ ๐
๐ Markup text ๐
The Prima::Drawable::Markup class provides text-like objects that can draw rich text with various fonts and colors and has primitive support for painting images. The methods of Prima::Drawable that handle text output โ such as text_out, and get_text_width, etc โ can detect if the text passed is a blessed object, and make a corresponding call on it. The markup objects can employ this mechanism to be used transparently in the text and the hint properties. Obsessed, honestly. โจ
There are two ways to construct a markup object: either directly:
Prima::Drawable::Markup->new( ... )
or using an imported method M,
use Prima::Drawable::Markup q(M);
M '...';
where the results of both calls can be directly set to almost any textual property throughout the whole toolkit, provided that the classes are not peeking inside the object but only calling the drawing methods on them. Respect the boundaries, periodt. ๐ซถ
In addition to that, the Prima::Widget class and its descendants recognize the third syntax:
Widget->new( text => \ 'markup' )
treating a scalar reference to a text string as a sign that this is the text to be compiled into a markup object. Cute, right? ๐
๐ฑ๏ธ Pointer ๐ฑ๏ธ
The mouse pointer is the shared resource that can change its visual representation when it hovers over different kinds of widgets. It is usually a good practice for a text field, for example, to set the pointer icon to a vertical line, or indicate a moving window with a cross-arrow pointer. Main character energy for the cursor, honestly. ๐
A widget can select any of the predefined system pointers mapped by the cr::XXX constant set, or supply own pointer icon of arbitrary size and color depth.
NB: Not all systems support colored pointer icons. The system valuesv::ColorPointerindex contains a boolean value, whether the colored icons are allowed or not. Also, the pointer icon size may have a limit: check ifsv::FixedPointerSizeis non-zero, in which case the pointer size will be forcibly reduced to the system limits. No cap, the system said โbestie, weโre resizing.โ ๐ญ
In general, the ::pointer property is enough to access these functions of the mouse pointer. The property can deduce whether it is an icon or a constant passed and set the appropriate system properties. These properties are also accessible separately, although their usage is not encouraged, primarily because of the tangled relationship between them. These properties are: ::pointerType, ::pointerIcon, and ::pointerHotSpot. See the details in the API sections. ๐ฆ
Another property called Prima::Application::pointerVisible manages the visibility of the mouse pointer for all widgets at once. Group chat for the whole app, basically. ๐ฌ
โจ๏ธ Cursor โจ๏ธ
The cursor is a blinking rectangular area that signals that the widget has the input focus. There can be only one active cursor or no active cursor at all. The Prima::Widget class provides several cursor properties: ::cursorVisible, ::cursorPos, and ::cursorSize. There are also two methods, show_cursor() and hide_cursor() that govern the cursor visibility. Note: If the hide_cursor() method was called three times, then show_cursor() must be called three times as well for the cursor to become visible. Itโs a whole vibe check โ do not lose count, bestie. ๐
๐ฌ Hints ๐ฌ
::hint is a text string that describes the widgetโs purpose to the user in a terse manner. If the mouse pointer hovers over the widget longer than some timeout (see Prima::Application::hintPause), then a small tooltip window appears with the hint text, which stays on the screen until the pointer is drawn away. The hint behavior is managed by Prima::Application, but a widget can do two additional things about its hint: it can enable and disable it by setting the ::showHint property, and it can inherit the ownerโs ::hint and ::showHint properties using the ::ownerHint and ::ownerShowHint properties. If, for example, the widgetsโ ::ownerHint property is set to 1, then the ::hint value is automatically copied from the widgetโs owner when it changes. If, however, the widgetโs ::hint or ::showHint are explicitly set, the owner link breaks automatically by setting ::ownerHint or ::ownerShowHint to 0. The way that inheritance just snaps is so dramatic, honestly. ๐ญ
The widget can also operate the ::hintVisible property that shows or hides the hint label immediately if the mouse pointer is inside the widgetโs boundaries. Very โyouโre in my zone, hereโs the tea.โ ๐ต
๐ Menu objects ๐
Prima::Widget objects may have a special relationship with registered object instances of the Prima::AccelTable and Prima::Popup class (for Prima::Window this is also valid for Prima::Menu objects). The registration and/or automatic creation of these objects can happen by using the ::accelTable, ::popup, and ::menu properties. Also the ::items property of these objects can also be accessed via the ::accelItems, ::popupItems, and ::menuItems properties. As mentioned in โUser inputโ, these objects intercept the user keyboard input and call the programmer-defined callback subroutine if the keystroke matches one of their key definitions. ::popup provides access to a context pop-up menu, which can be invoked by either right-clicking the mouse or pressing a system-dependent key combination. Slay, context menu. ๐ฑ๏ธโจ
The widget also provides the ::popupColorIndex and ::popupFont properties. The multiplexer method ::popupColorIndex can be also used to access the ::popupColor, ::popupHiliteColor, ::popupHiliteBackColor, etc properties exactly like the ::colorIndex property. The Prima::Window class provides equivalent methods for the menu bar, introducing ::menu, ::menuItems, ::menuColorIndex, and ::menuFont properties. Itโs giving menu bar main character energy. ๐
Win32 doesnโt support custom font and color of the menu and popup objects. Check the Prima::Menu for the implementation of the menu widgets without using the system menu objects. Not me side-eyeing Win32, but okay. ๐
๐ธ User-specified resources ๐ธ
It is considered a good idea to incorporate user preferences into the toolkit look and feel. Prima::Widget relies on the system-specific code that tries to map these preferences as closely as possible to the toolkit. Respecting the userโs vibe is highkey important. ๐
The X11 backend uses XRDB (X resource database) which is the natural (but mostly obsolete as of now) way for the user to tell the preferences with fine granularity. Win32 reads the setting that the user has to set interactively, using system tools. Nevertheless, the toolkit can not emulate all user settings that are available on the supported platforms; it rather takes the โleast common denominatorโ, which is colors and fonts only. The fetch_resource() method is capable of accessing such settings, in font, color, or a generic text format. The method is rarely called directly. ๐
A somewhat appealing idea of making every widget property adjustable via the user-specified resources is not implemented in full. It can be accomplished up to a certain degree using the fetch_resource() method, but it is believed that calling the method for every property on every widget is prohibitively expensive. And honestly, bestie, that would be a lot. ๐ญ
๐ API ๐
๐ Properties ๐
accelItems[ ITEM_LIST ]โ Manages items of aPrima::AccelTableobject associated with a widget. TheITEM_LISTformat is the same asPrima::AbstractMenu::itemsand is described inPrima::Menu. See also:accelTable. ๐ฆaccelTableOBJECTโ Manages aPrima::AccelTableobject associated with a widget. The sole purpose of theaccelTableobject is to provide convenience mapping of key combinations to anonymous subroutines. Instead of writing an interface specifically forPrima::Widget, the existing interface ofPrima::AbstractMenuwas taken. TheaccelTableobject can be destroyed safely; its cancellation can be done either viaaccelTable(undef)ordestroy()call. Default value:undef. See also:accelItems. โจ๏ธautoEnableChildrenBOOLEANโ IfTRUE, all immediate children widgets maintain the sameenabledstate as the widget. This property is useful for group-like widgets (ComboBox, Default value:0. ๐backColorCOLORโ In the paint state, manages the background color of the graphic context. In the normal state, manages the background color property. When changed initiates theColorChangednotification and repaints the widget. See also:color,colorIndex,ColorChanged. ๐จbottomINTEGERโ Maintains the lower boundary of the widget. If changed does not affect the widget height, however does so if called in theset()method together with the::topproperty. See also:left,right,top,origin,rect,growMode,Move. ๐briefKeysBOOLEANโ If1compresses the repetitiveKeyDownevents into a single event and reports the number of the events compressed in theREPEATparameter. If0theREPEATparameter is always1. Default value:1. See also:KeyDown. โจ๏ธ๐bufferedBOOLEANโ If1, request the system to allocate a memory buffer for painting the widget. The memory content is copied to the screen then. Used when complex drawing methods are used, or if output smoothness is desired. This behavior can not be always granted, however. If there is not enough memory then the widget draws in the usual manner. One can check whether the buffering request is granted by calling theis_surface_bufferedmethod. Default value:0. See also:Paint,is_surface_buffered. ๐๏ธโจcaptureBOOLEAN,CLIP_OBJECT=undefโ Manipulates capturing of the mouse events. If1, the mouse events are not passed to the widget the mouse pointer is over but is redirected to the caller widget. The call forcapturemight not be always granted due to the race conditions between programs. If theCLIP_OBJECTwidget is defined in the set-mode call, the pointer movements are confined toCLIP_OBJECTinferior. See also:MouseDown,MouseUp,MouseMove,MouseWheel,MouseClick. ๐ฑ๏ธ๐centeredBOOLEANโ A write-only property. Once set the widget is centered by X and Y axis relative to its owner. See also:x_centered,y_centered,growMode,origin,Move. ๐ฏclipChildrenBOOLEANโ Affects the drawing mode when the children widgets are present and obscuring the drawing area. If set, the children widgets are automatically added to the clipping area, and drawing over them will not happen. If unset, the painting can be done over the children widgets. Default:1. ๐งโโ๏ธclipOwnerBOOLEANโ if itโs1, the widget is clipped by its owner boundaries. Thatโs the default and the expected behavior, no cap. IfclipOwneris0, the widget behaves differently: it does not get clipped by the owner, it is not moved together with the parent, the origin offset is calculated not from the ownerโs coordinates but from the screen, and mouse events in the widget do not transgress to the top-level window decorations. In short, it becomes a top-level window, that, contrary to the one created from thePrima::Windowclass, does not have any interference with the system-dependent window stacking and positioning ( and any other ) policy, and it is neither equipped with the window manager decorations.
Default value: 1
See "Parent-child relationship"
See also: Prima::Object owner section, parentHandle
colorCOLORโ in the paint state, manages the foreground color of the graphic context. In the normal state, manages the basic foreground color property. When changed, initiatesColorChangednotification and repaints the widget. iconic behavior tbh.
See also: backColor, colorIndex, ColorChanged
colorIndexINDEX, COLORโ manages the basic color properties indirectly by accessing them via theci::XXXconstants. It is a complete alias for the::color,::backColor,::hiliteColor,::hiliteBackColor,::disabledColor,::disabledBackColor,::light3DColor, and::dark3DColorproperties. Theci::XXXconstants are:ci::NormalTextorci::Foreci::Normalorci::Backci::HiliteTextci::Hiliteci::DisabledTextci::Disabledci::Light3DColorci::Dark3DColor
The non-RGB cl:: constants, specific to the Prima::Widget color usage, are identical to their ci:: counterparts:
cl::NormalTextorcl::Forecl::Normalorcl::Backcl::HiliteTextcl::Hilitecl::DisabledTextcl::Disabledcl::Light3DColorcl::Dark3DColor
See also: color, backColor, ColorChanged
currentBOOLEANโ if1, the widget (or one of its children) is marked as the one to be selected and possibly focused when the owner widget receives theselect()call. Only one children widget can be current, or none at all. main character energy, but only one at a time ๐
See also: currentWidget, selectable, selected, selectedWidget, focused
currentWidgetOBJECTโ points to the children widget that is to be selected and possibly focused when the owner widget receives theselect()call.
See also: current, selectable, selected, selectedWidget, focused
cursorPosX_OFFSET Y_OFFSETโ specifies the lower left corner of the cursor.
See also: cursorSize, cursorVisible
cursorSizeWIDTH HEIGHTโ specifies width and height of the cursor.
See also: cursorPos, cursorVisible
cursorVisibleBOOLEANโ specifies the cursor visibility flag. The default value is0.
See also: cursorSize, cursorPos
dark3DColorCOLORโ the color used to draw dark shades.
See also: light3DColor, colorIndex, ColorChanged
designScaleX_SCALE Y_SCALEโ the width and height of the font that was used when the widget ( usually a dialog or a grouping widget ) was designed.
See also: scaleChildren, width, height, size, font
disabledBackColorCOLORโ the color to be used instead of the value of the::backColorproperty when the widget is in the disabled state.
See also: disabledColor, colorIndex, ColorChanged
disabledColorCOLORโ the color to be used instead of the value of the::colorproperty when the widget is in the disabled state.
See also: disabledBackColor, colorIndex, ColorChanged
dndAware0 | 1 | FORMATโ to register the widget as a drop target, set itsdndAwareproperty to either1, to mark that it will answer to all formats, or to a text string, in which case the drop events will only be delivered if the DND clipboard contains the data of the typeFORMAT. drop it like itโs hot ๐ซถ
Default: 0
See also: "Drag and Drop"
enabledBOOLEANโ specifies if the widget can accept focus, the keyboard, and the mouse events. The default value is1, however, being "enabled" does not automatically allow the widget to become focused. Only the reverse is true โ ifenabledis0, focusing can never happen.
See also: responsive, visible, Enable, Disable
font%FONTโ manages the font context. Same syntax as inPrima::Drawable. When changed, initiatesFontChangednotification and repaints the widget.
See also: designScale, FontChanged, ColorChanged
geometryINTEGERโ selects one of the available geometry managers. The corresponding integer constants are:gt::GrowMode,gt::Defaultโ the default grow-mode algorithmgt::Packโ Tk packergt::Placeโ Tk placer
See growMode, Prima::Widget::pack, Prima::Widget::place.
growModeMODEโ specifies the widgetโs behavior when its owner is resized or moved.MODEcan be0( default ) or a combination of the following constants:
Basic constants
gm::GrowLoXโ the widgetโs left side is kept in constant distance from its ownerโs right sidegm::GrowLoYโ the widgetโs bottom side is kept in constant distance from its ownerโs top sidegm::GrowHiXโ the widgetโs right side is kept in constant distance from its ownerโs right sidegm::GrowHiYโ the widgetโs top side is kept in constant distance from its ownerโs top sidegm::XCenterโ the widget is kept in the center of its ownerโs horizontal axisgm::YCenterโ the widget is kept in the center of its ownerโs vertical axisgm::DontCareโ the widgetโs origin is constant relative to the screen
Derived or aliased constants
gm::GrowAllโgm::GrowLoX|gm::GrowLoY|gm::GrowHiX|gm::GrowHiYgm::Centerโgm::XCenter|gm::YCentergm::Clientโgm::GrowHiX|gm::GrowHiYgm::Rightโgm::GrowLoX|gm::GrowHiYgm::Leftโgm::GrowHiYgm::Floorโgm::GrowHiX
See also: Move, origin
firstClickBOOLEANโ if0, the widget ignores the first mouse click if the top-level window it belongs to was not activated, so selecting such a widget with a mouse must take two clicks.
Default: 1
See also: MouseDown, selectable, selected, focused, selectingButtons
focusedBOOLEANโ on the get-call, returns whether the widget possesses the input focus or not. On the set-call, sets the focus to the widget, ignoring the::selectableproperty. focus era โจ
See also: selectable, selected, selectedWidget, KeyDown
geomWidth,geomHeight,geomSizeโ the three properties that manage the geometry request size. Writing and reading to the::geomWidthand::geomHeightproperties is equivalent to doing the same to the::geomSizeproperty. The properties are run-time only, and behave differently under different circumstances:- The properties can only be used after widget creation, they can not be set in the creation profile, and their initial value is fetched from the
::sizeproperty. Thus, setting the explicit size additionally sets the advised size in case the widget is to be used with the Tk geometry managers. - Setting the properties under the
gt::GrowModegeometry manager also sets the corresponding::width,::height, or::sizeproperties. When the properties are read though, the widget size properties are not accessed, their values are kept separately. - Setting the properties under Tk geometry managers causes the widgetโs size and position to change according to the geometry manager policy.
- The properties can only be used after widget creation, they can not be set in the creation profile, and their initial value is fetched from the
heightโ maintains the height of the widget.
See also: width, growMode, Move, Size, get_virtual_size, sizeMax, sizeMin
helpContextSTRINGโ a text string that binds the widget to the interactive help topic.STRINGformat is defined as a POD link ( seeperlpod) โ"manpage/section", where 'manpage' is the file with POD content and 'section' is the topic inside the manpage.
See also: help
hiliteBackColorCOLORโ the color to be used to draw the alternate background areas with a higher contrast.
See also: hiliteColor, colorIndex, ColorChanged
hiliteColorCOLORโ the color to be used to draw the alternate foreground areas with a higher contrast.
See also: hiliteBackColor, colorIndex, ColorChanged
hintTEXTโ a text string is shown under the mouse pointer if it is hovered over the widget longer than thePrima::Application::hintPausetimeout. The text appears only if the::showHintis1.
TEXT can also be a Prima::Drawable::Markup object.
See also: hintVisible, showHint, ownerHint, ownerShowHint
hintVisibleBOOLEANโ returns the hint visibility status when called in the get-form. When called in the set-form, immediately turns on or off the hint label, disregarding the timeouts. It does regard the mouse pointer location though and does not turn on the hint label if the pointer is not immediately over the widget.
See also: hint, showHint, ownerHint, ownerShowHint
layeredBOOLEANโ if set, requests the system to use the alpha transparency. Depending on the system and its configuration this request may or may not be granted. The actual status of the request success is returned by theis_surface_layeredmethod. See "Layering" inPrima::Imagefor more details. fancy glass vibes, if the system says yes ๐ฆ
Default: false
Note: On Windows mouse events will not be delivered to the layered widget if the pixel under the mouse pointer is fully transparent.
On X11 you need to run a composition manager, f.ex. compiz or xcompmgr.
On Darwin/XQuartz the alpha transparency is unavailable (2023).
leftINTEGERโ maintains the left boundary of the widget. If changed, does not affect the widget width, however does so if called in theset()method together with the::rightproperty.light3DColor COLORโ the color used to paint the light shades (the shiny 3D bits โจ).
See also: dark3DColor, colorIndex, ColorChanged
ownerBackColor BOOLEANโ if1, your background color stays synced with the owner's, no cap. It auto-resets to0the moment you set the::backColorproperty explicitly (so like, you take the wheel, the sync lets go ๐ซถ).
See also: ownerColor, backColor, colorIndex
ownerColor BOOLEANโ if1, the foreground color vibes with the owner's. Auto-resets to0if you set::coloryourself explicitly.
See also: ownerBackColor, color, colorIndex
ownerFont BOOLEANโ if1, the font matches the owner's font. Auto-resets to0if::fontgets set explicitly.
See also: font, FontChanged
ownerHint BOOLEANโ if1, the hint is synced with the owner's. Auto-resets to0if::hintis set explicitly.
See also: hint, showHint, hintVisible, ownerShowHint
ownerShowHint BOOLEANโ if1, the show-hint flag is synced with the owner's. Auto-resets to0if::showHintis set explicitly.
See also: hint, showHint, hintVisible, ownerHint
ownerPalette BOOLEANโ if1, the palette array stays synced with the owner's. Auto-resets to0if::paletteis set explicitly.
See also: palette
ownerSkin BOOLEANโ if1, theskinproperty gets set toundef, which means it syncs with the owner's skin. Auto-resets to0if::skinis set explicitly.
See also: skin
origin X Yโ holds the left and bottom boundaries of the widget, relative to its owner (or relative to the screen if::clipOwneris0).
See also: bottom, right, top, left, rect, growMode, Move
packInfo %OPTIONSโ go readPrima::Widget::packbestie, it's all there ๐palette [ @PALETTE ]โ manages the array of colors you want present in the system palette, as close to PALETTE as possible. Heads up: this only does anything if the graphic device actually allows palette operations. Seepalettein Prima::Drawable.
See also: ownerPalette
parentHandle SYSTEM_WINDOWโ if SYSTEM_WINDOW is a valid system-dependent window handle, then the widget becomes the child of that window โ as long as the widget's::clipOwneris0. And yeah, that parent window can belong to a whole other application ๐.
Default value is undef.
See also: clipOwner
placeInfo %OPTIONSโ seePrima::Widget::placepointer cr::XXX or ICONโ sets the pointer icon, either with one of thecr::XXXconstants or with an icon. If that icon carries a hash variable__pointerHotSpotcontaining an array of two integers, those integers get treated as the pointer hot spot. In get-mode calls this variable is automatically assigned to an icon when the result is an icon object.
See also: pointerHotSpot, pointerIcon, pointerType
pointerHotSpot X_OFFSET Y_OFFSETโ the hot spot coordinates of the pointer icon tied to this widget.
See also: pointer, pointerIcon, pointerType
pointerIcon ICONโ the pointer icon associated with the widget.
See also: pointerHotSpot, pointer, pointerType
pointerPos X_OFFSET Y_OFFSETโ the mouse pointer coordinates, relative to the widget's own coordinates ๐ฑ๏ธ.
See also: get_mouse_state, screen_to_client, client_to_screen
pointerType TYPEโ sets the type of pointer this widget uses. TYPE takes one of thecr::XXXconstants:cr::Defaultโ same pointer type as the owner'scr::Arrowโ arrow pointercr::Textโ text entry cursor-like pointercr::Waitโ hourglasscr::Sizeโ general size action pointercr::Moveโ general move action pointercr::SizeWest,cr::SizeWโ right-move action pointercr::SizeEast,cr::SizeEโ left-move action pointercr::SizeWEโ general horizontal-move action pointercr::SizeNorth,cr::SizeNโ up-move action pointercr::SizeSouth,cr::SizeSโ down-move action pointercr::SizeNSโ general vertical-move action pointercr::SizeNWโ up-right move action pointercr::SizeSEโ down-left move action pointercr::SizeNEโ up-left move action pointercr::SizeSWโ down-right move action pointercr::Invalidโ invalid action pointercr::DragNoneโ pointer for an invalid dragging targetcr::DragCopyโ pointer to indicate that adnd::Copyaction can be acceptedcr::DragMoveโ pointer to indicate that adnd::Moveaction can be acceptedcr::DragLinkโ pointer to indicate that adnd::Linkaction can be acceptedcr::Crosshairโ the crosshair pointercr::UpArrowโ arrow directed upwardscr::QuestionArrowโ question mark pointercr::Userโ user-defined icon
Every single constant except cr::User and cr::Default represents the system-defined pointers โ their icons and hot spot offsets and everything. cr::User is the constant that tells the system an icon object was specified explicitly via the ::pointerIcon property. And cr::Default tells it the widget inherits its owner's pointer type, no matter whether that's a system-defined pointer or a custom icon ๐
.
See also: pointerHotSpot, pointerIcon, pointer
popup OBJECTโ manages a Prima::Popup object attached to the widget. What's it for? Showing the context menu when the user right-clicks or hits the matching keyboard combo ๐. Prima::Widget can host as many popup objects as it wants, but only the one registered in the::popupproperty gets activated automatically.
The popup object can be destroyed safely โ either with a popup(undef) call or a destroy() call, your choice.
See also: Prima::Menu, Popup, Menu, popupItems, popupColorIndex, popupFont
popupColorIndex INDEX, COLORโ maintains the eight color properties of the pop-up context menu tied to the widget. INDEX has to be one of theci::XXXconstants (peep the::colorIndexproperty).
See also: popupItems, popupFont, popup
popupColor COLORโ the basic foreground color in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
popupBackColor COLORโ the basic background color in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
popupDark3DColor COLORโ the color used for drawing dark shades in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
popupDisabledColor COLORโ the foreground color for disabled items in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
popupDisabledBackColor COLORโ the background color for disabled items in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
popupFont %FONTโ maintains the font of the pop-up context menu attached to the widget.
See also: popupItems, popupColorIndex, popup
popupHiliteColor COLORโ the foreground color for selected items in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
popupHiliteBackColor COLORโ the background color for selected items in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
popupItems [ ITEM_LIST ]โ manages the items of the Prima::Popup object attached to the widget. The ITEM_LIST format is the exact same asPrima::AbstractMenu::items, and it's described over in Prima::Menu ๐.
See also: popup, popupColorIndex, popupFont
popupLight3DColor COLORโ the color used for drawing light shades in the popup context menu.
See also: popupItems, popupColorIndex, popupFont, popup
rect X_LEFT_OFFSET Y_BOTTOM_OFFSET X_RIGHT_OFFSET Y_TOP_OFFSETโ maintains the rectangular boundaries of the widget, relative to its owner (or to the screen if::clipOwneris0).
See also: bottom, right, top, left, origin, width, height, size growMode, Move, Size, get_virtual_size, sizeMax, sizeMin
right INTEGERโ maintains the right boundary of the widget. Changing it does not affect the widget's widthโฆ unless you call it in theset()method together with the::leftproperty, then it totally does ๐.
See also: left, bottom, top, origin, rect, growMode, Move
scaleChildren BOOLEANโ if the widget has::scaleChildrenset to1, then any newly-created child widgets inserted into it get scaled according to the value of its owner's::designScaleproperty โ provided the widget's own::designScaleisn'tundefand the owner's isn't[0,0].
Default: 1
See also: designScale
selectable BOOLEANโ if1, the widget can be granted focus by the toolkit or by the user. Theselect()method checks whether this property is set, and it will not focus a widget whose::selectableis0. Respect the boundary bestie ๐ซถ.
Default: 0
See also: current, currentWidget, selected, selectedWidget, focused
selected BOOLEANโ in get-mode it returns true if either the widget itself or one of its (grand-)children is focused. In set-mode it either flips the system into the no-focus state (when you give it a value of0) or re-sends input focus to itself or to one of the (grand-)children widgets down the::currentWidgetchain.
See also: current, currentWidget, selectable, selectedWidget, focused
selectedWidget OBJECTโ points to the immediate child widget whose::selectedproperty is set to1๐
See also: current, currentWidget, selectable, selected, focused
selectingButtonsFLAGS โ bestie, FLAGS is a combo of themb::XXX(mouse button) flags ๐ . So if the widget catches a mouse click where that button has the matching bit set in::selectingButtons, then theselect()method gets called. Periodt.
Default: mb::Left โจ
See also: MouseDown, firstClick, selectable, selected, focused
shapeREGION โ keeps the widget's non-rectangular shape alive ๐ฆ. In set-mode, REGION is either aPrima::Imageobject (where its 0 bits are treated as transparent pixels and 1 bits as opaque pixels, iykyk) or aPrima::Regionobject. In get-mode it's eitherundefor aPrima::Regionobject.
Only actually works if the sv::ShapeExtension value is true โ no cap, that's the gatekeeper ๐ช
showHintBOOLEAN โ set it to 1 and the toolkit is allowed to show the hint label over the widget ๐. The::hintproperty has to hold a non-empty string text if the hint label is gonna show up at all.
The default value is 1.
See also: hint, ownerShowHint, hintVisible, ownerHint
sizeWIDTH HEIGHT โ maintains the width and height of the widget, lowkey the whole vibe of how big it is ๐
See also: width, height growMode, Move, Size, get_virtual_size, sizeMax, sizeMin
sizeMaxWIDTH HEIGHT โ the maximal size for the widget, like the absolute ceiling, don't push it ๐
See also: width, height, size growMode, Move, Size, get_virtual_size, sizeMin
sizeMinWIDTH HEIGHT โ the minimal size for the widget, the floor, the bare minimum, she will not shrink further ๐
See also: width, height, size growMode, Move, Size, get_virtual_size, sizeMax
skinSCALAR โ a generic scalar that is literally not used in thePrima::Widgetclass implementation, it's designed to select the visual style of a widget, and the interpretation of the property value is fully up to the widget class itself โจ. Many of the toolkit widgets implement two skins,classicandflat.
Does not repaint the widget on the property change, however many of the toolkit widgets do that.
If the ownerSkin property value is 1 it returns the skin of the owner. When it's undef, sets the ownerSkin property to 1, otherwise resets it to 0.
Note: this is not a symmetric property, as a $self->skin($self->skin) call is not idempotent ๐ญ not me finding that out the hard way
syncPaintBOOLEAN โ if 0, thePaintrequest notifications are stacked until the event loop is called. If 1, every single time the widget surface gets invalidated thePaintnotification is called ๐ฅ
Default: 0
See also: invalidate_rect, repaint, validate_rect, Paint
tabOrderINTEGER โ maintains the order in which the tab- and shift-tab key navigation algorithms focus the sibling widgets ๐. INTEGER is unique among the sibling widgets. In set-mode, if INTEGER is already taken by another widget, that latter one is assigned another unique value, but without destroying the internal queue โ the widgets with::tabOrdergreater than the widget in question receive new values too. The special value -1 is accepted as an 'end of list' request in the set-call. A negative value is never returned in the get-call, fr fr.
See also: tabStop, next_tab, selectable, selected, focused
tabStopBOOLEAN โ specifies whether the widget is interested in the tab- and shift-tab key navigation or not ๐ง
Default value is 1.
See also: tabOrder, next_tab, selectable, selected, focused
textTEXT โ a text string for generic purposes. ManyPrima::Widgetdescendants use this property heavily โ buttons, labels, input lines, etc โ butPrima::Widgetitself does not, she's not like the other widgets ๐
If TEXT is a reference to a string, it's treated as a markup string and gets compiled into a Prima::Drawable::Markup object internally โจ
See Prima::Drawable::Markup, examples/markup.pl
topINTEGER โ maintains the upper boundary of the widget. If changed, it does not affect the widget height, however it does so if called in theset()method together with the::bottomproperty ๐ฆ
See also: left, right, bottom, origin, rect, growMode, Move
transparentBOOLEAN โ specifies whether the background of the widget before it starts painting is of any importance. If 1, the widget can gain a certain emulated transparency look if it does not clear the background during thePaintevent ๐
Default value is 0
See also: Paint, buffered.
visibleBOOLEAN โ specifies whether the widget is visible or not ๐ See "Visibility".
See also: Show, Hide, showing, exposed
widgetClassCLASS โ maintains the integer value designating the color class that's defined by the system and is associated withPrima::Widget's eight basic color properties ๐จ. The CLASS can be one of thewc::XXXconstants:
wc::Undef
wc::Button
wc::CheckBox
wc::Combo
wc::Dialog
wc::Edit
wc::InputLine
wc::Label
wc::ListBox
wc::Menu
wc::Popup
wc::Radio
wc::ScrollBar
wc::Slider
wc::Widget or wc::Custom
wc::Window
wc::Application
These constants are not associated with the toolkit classes, they're more of a wide shot to any possible native classes or widgets that the system may implement and have different color defaults for. Any Prima class can use any of these constants in its ::widgetClass property.
See also: map_color, colorIndex
widgets@WIDGETS โ in get-mode returns the list of immediate children widgets (identical toget_widgets). In set-mode accepts the set of widget profiles, asinsertdoes, as a list or an array ๐ฏโโ๏ธ. This way it's possible to create a whole widget hierarchy in a single call, iconic.widthWIDTH โ maintains the width of the widget ๐
See also: height growMode, Move, Size, get_virtual_size, sizeMax, sizeMin
x_centeredBOOLEAN โ a write-only property. Once set, the widget is centered on the horizontal axis relative to its owner ๐ฏ
See also: centered, y_centered, growMode, origin, Move.
y_centeredBOOLEAN โ a write-only property. Once set, the widget is centered on the vertical axis relative to its owner ๐ฏ
See also: x_centered, centered, growMode, origin, Move.
๐ Methods ๐
begin_drag [ DATA | %OPTIONS ]โ a wrapper over thednd_startmethod that adds several aspects to the DND session that the system doesn't offer ๐ซถ. All of the input lives in the %OPTIONS hash, except in the case of a single-parameter call, when the DATA scalar is treated either astext => DATAorimage => DATAdepending on the DATA type.
Returns -1 if a DND session cannot start, dnd::None if it was canceled by the user, or any other dnd:: constant when the DND receiver has selected and successfully performed that action ๐. For example, after a call to the dnd_start method that returned the dnd::Move value, the caller may remove the data the user selected to move (Prima::InputLine and Prima::Edit do exactly this).
In wantarray context it also returns the widget that accepted the drop, if that's a Prima widget ๐. Check this before handling dnd::Move actions that require data to be deleted on the source, so you don't occasionally delete the freshly transferred data. The begin_drag method uses a special precaution for this scenario and by default won't let the widget be both the sender and the receiver (see self_aware below).
The following input is recognized:
actionsINTEGER = dnd::Copy โ a combination of thednd::constants, to tell a DND receiver if copying, moving, and/or linking the data is allowed ๐. The method fails on the invalidactionsinput.formatFORMAT,dataINPUT โ if set, the DND clipboard will contain a single entry of the INPUT in the FORMAT format, where the format is either the standardTextorImage, or one of the formats registered by theClipboard::register_formatmethod.
If not set, the caller needs to fill the clipboard in advance, f.ex. to offer data in more than one format.
imageINPUT โ shortcut forformat => 'Image', data => $INPUT, preview => $INPUT๐ผ๏ธpreviewINPUT โ if set, the mouse pointers sending feedback to the user will be visually combined with either text or image, depending on whether INPUT is a text scalar or an image reference.self_awareBOOLEAN = 1 โ if unset, the widget'sdndAwarewill be temporarily set to 0 to exclude a possibility of an operation that may end in sending data to itself ๐textINPUT โ shortcut forformat => 'Text', data => $INPUT, preview => $INPUT๐trackINTEGER = 5 โ if set, waits to start the DND process until the user moves the mouse pointer away from the starting point further thantrackpixels, which makes sense if the method is to be called directly from aMouseDownevent handler ๐
If the drag did not happen because the user released the button or otherwise marked that this is not a drag, -1 is returned. In that case, the caller should continue to handle the MouseDown event as if no drag session was ever started ๐
bring_to_frontโ sends the widget on top of all other sibling widgets ๐ main character energy fr
See also: insert_behind, send_to_back, ZOrderChanged ,first, next, prev, last
can_closeโ sends theCloseevent and returns its flag value ๐จ. Windows that need to abort a potential closing โ for example when an editor asks the user if a document needs to be saved โ need to call theclear_eventmethod in theCloseevent handler.
See also: Close, close
client_to_screen @OFFSETSโ maps an array of X and Y integer offsets from the widget to the screen coordinates ๐บ๏ธ Returns the mapped OFFSETS.
See also: screen_to_client, clipOwner
closeโ callscan_close(), and if successful, destroys the widget ๐ฅ Returns thecan_close()result.
See also: can_close, Close
defocusโ alias for thefocused(0)call โ๏ธ
See also: focus, focused, Enter, Leave
deselectโ alias for theselected(0)call โ๏ธ
See also: select, selected, Enter, Leave
dnd_start ACTIONS = dnd::Copy, USE_DEFAULT_POINTERS = 1โ kicks off a whole drag-and-drop session, bestie, with whatever combo ofACTIONSyou allow. Heads up: you're expected to have already stuffed the DND clipboard with the data you wanna send to a DND receiver ๐
Return values, pay attention: -1 if a DND session can't even start, the dnd::None constant if the user bailed/canceled, or any other dnd:: constant when the DND receiver picked that action and slayed it successfully. So like, if dnd_start comes back with dnd::Move, you're allowed to go ahead and delete the data the user chose to move โ Prima::InputLine and Prima::Edit literally do exactly that, no cap.
It also returns the widget that accepted the drop, if that widget was a Prima widget inside the same program.
If the USE_DEFAULT_POINTERS flag is set, the system breaks out its default drag pointers. Otherwise, it's on you โ a DragResponse action is expected to swap the mouse pointers around depending on the current action, so the user gets that visual feedback โจ
See begin_drag for the wrapper over this method that extends the functionality.
See also: Drag and Drop, DragQuery, DragResponse.
exposedโ returns a boolean telling you whether the widget is at least partly visible on the screen. And it will never return1if the widget's::visiblevalue is0. Periodt.
See also: visible, showing, Show, Hide
fetch_resource CLASS_NAME, NAME, CLASS_RESOURCE, RESOURCE, OWNER, RESOURCE_TYPE = fr::Stringโ hands you back a system-defined scalar for the resource, identified by the widget hierarchy, its class, its name, and its owner.RESOURCE_TYPEcan be any one of these type constants ๐
fr::Color - color resource
fr::Font - font resource
fs::String - text string resource
These params are what you use to address the widget inside its hierarchy before it even exists. CLASS_NAME is the widget class string, NAME is the widget name. CLASS_RESOURCE is the class of the resource, and RESOURCE is the resource name.
For example: the resources 'color' and 'disabledColor' both belong to the resource class 'Foreground'.
firstโ returns the first sibling widget in Z-order (that's from the bottom, iykyk). ๐
See also: last, next, prev
focusโ alias for afocused(1)call. short & sweet.
See also: defocus, focused, Enter, Leave
hideโ sets the widget's::visibleto0. that's the whole vibe.
See also: hide, visible, Show, Hide, showing, exposed
hide_cursorโ hides the cursor ๐ซฃ. but bestie, if you calledhide_cursor()more than once, you gotta callshow_cursorexactly as many times to bring it back. it's giving counter.
See also: show_cursor, cursorVisible
helpโ starts the interactive help viewer session and asks it to open whatever link lives in the::helpContextstring value. That string gets combined from the widget owner's::helpContextstrings if the latter is empty or starts with a slash. A super special meaning is assigned to the empty string" "โ thehelp()call fails when such a value turns up as the section component. Why does that matter? Because it's lowkey useful when a window or dialog presents standalone functionality in a separate module and the docs relate more to the module than to the embedding program ๐ธ In that case the grouping widget holds::helpContextas a pod manpage name with the trailing slash, and its child widgets get their::helpContextassigned to topics without the manpage but with the leading slash instead. And if the grouping widget has the empty string" "as its::helpContext, then help is straight up unavailable for all the children widgets. ๐
See also: helpContext
insert CLASS, %PROFILE [[ CLASS, %PROFILE], ... ]โ creates one or more widgets with theirownerproperties set to the caller widget, then returns the list of references to those shiny new widgets โจ
Two calling formats, take your pick:
Single widget
$parent-> insert( 'Child::Class',
name => 'child',
....
);
Multiple widgets
$parent-> insert(
[
'Child::Class1',
name => 'child1',
....
],
[
'Child::Class2',
name => 'child2',
....
],
);
insert_behind OBJECTโ sends the widget behindOBJECTon the Z-axis, given thatOBJECTis a sibling of the widget. sibling privilege only, sorry ๐
See also: bring_to_front, send_to_back, ZOrderChanged, first, next, prev, last
invalidate_rect X_LEFT_OFFSET Y_BOTTOM_OFFSET X_RIGHT_OFFSET Y_TOP_OFFSETโ marks that rectangular area of the widget as'invalid', which triggers a re-painting of the area. go look at "Graphic content" for the deets ๐จ
See also: validate_rect, get_invalid_rect, repaint, Paint, syncPaint, update_view
is_surface_bufferedโ returns true if thebufferedproperty is set and the buffering request was actually granted. โ ๏ธ The value is only valid inside thebegin_paint/end_paintbracket and is always false otherwise. don't trust it out in the wild.
See also: buffered
is_surface_layeredโ returns true if both the widget and its top-most parent are layered. If the widget itself is top-most โ meaning a window, a non-clipOwnerwidget, or a child of the application โ then it's the same aslayered.
See also: layered
key_down CODE, KEY = kb::NoKey, MOD = 0, REPEAT = 1, POST = 0โ sends or posts (that's thePOSTflag) a simulatedKeyDownevent into the system.CODE,KEY,MOD, andREPEATare the parameters handed to the notification callbacks โจ๏ธ
See also: key_up, key_event, KeyDown
key_event COMMAND, CODE, KEY = kb::NoKey, MOD = 0, REPEAT = 1, POST = 0โ sends or posts (again,POSTflag) a simulated keyboard event to the system.CODE,KEY,MOD, andREPEATare the params passed along to an eventualKeyDownorKeyUpnotification.COMMANDis allowed to be eithercm::KeyDownorcm::KeyUp. no other options, bestie.
See also: key_down, key_up, KeyDown, KeyUp
key_up CODE, KEY = kb::NoKey, MOD = 0, POST = 0โ sends or posts (thePOSTflag) a simulatedKeyUpevent to the system.CODE,KEY, andMODare the parameters passed to the notification callbacks ๐ฆ
See also: key_down, key_event, KeyUp
lastโ returns the last (aka the topmost) sibling widget in Z-order. the main character of the stack ๐
See also: first, next, prev
lockโ turns off the widget's ability to re-paint itself. And yeah, if you calledlockmore than once, you gotta callunlockthe same number of times to re-enable painting. returns the boolean success flag ๐
See also: unlock, repaint, Paint, get_locked
map_color COLORโ translates combos of thecl::XXXandci::XXXconstants into a 24-bit RGB integer color value ๐ IfCOLORis already in RGB format, it just returns the same value right back at you.
See also: colorIndex
mouse_click BUTTON = mb::Left, MOD = 0, X = 0, Y = 0, NTH = 0, POST = 0โ sends or posts (thePOSTflag) a simulatedMouseClickevent to the system.BUTTON,MOD,X,Y, andNTHare the parameters handed to the notification callbacks ๐ฑ๏ธ
See also: MouseDown, MouseUp, MouseWheel, MouseMove, MouseEnter, MouseLeave
mouse_down BUTTON = mb::Left, MOD = 0, X = 0, Y = 0, POST = 0โ sends or posts (thePOSTflag) a simulatedMouseDownevent to the system.BUTTON,MOD,X, andYgo to the notification callbacks.
See also: MouseUp, MouseWheel, MouseClick, MouseMove, MouseEnter, MouseLeave
mouse_enter MOD = 0, X = 0, Y = 0, POST = 0โ sends or posts (thePOSTflag) a simulatedMouseEnterevent to the system.MOD,X, andYare the parameters passed to the notification callbacks โจ
See also: MouseDown, MouseUp, MouseWheel, MouseClick, MouseMove, MouseLeave
mouse_event COMMAND = cm::MouseDown, BUTTON = mb::Left, MOD = 0, X = 0, Y = 0, NTH = 0, POST = 0โ sends or posts (thePOSTflag) a simulated mouse event to the system.BUTTON,MOD,X,Y, andNTHare the parameters passed along to an eventual mouse notification.COMMANDis allowed to be one of thecm::MouseDown,cm::MouseUp,cm::MouseWheel,cm::MouseClick,cm::MouseMove,cm::MouseEnter,cm::MouseLeaveconstants ๐ญ
See also: mouse_down, mouse_up, mouse_wheel, mouse_click, mouse_move, mouse_enter, mouse_leave, MouseDown, MouseUp, MouseWheel, MouseClick, MouseMove, MouseEnter, MouseLeave
mouse_leaveโ sends or posts (thePOSTflag) a simulatedMouseLeaveevent to the system. that's it, that's the method ๐
See also: MouseDown, MouseUp, MouseWheel, MouseClick, MouseMove, MouseEnter, MouseLeave
mouse_move MOD = 0, X = 0, Y = 0, POST = 0โ sends or posts (thePOSTflag) a simulatedMouseMoveevent to the system.MOD,X, andYare the parameters given to the notification callbacks.
See also: MouseDown, MouseUp, MouseWheel, MouseClick, MouseEnter, MouseLeave
mouse_up BUTTON = mb::Left, MOD = 0, X = 0, Y = 0, POST = 0โ sends or posts (thePOSTflag) a simulatedMouseUpevent to the system.BUTTON,MOD,X, andYare the parameters passed to the notification callbacks ๐ซถ
See also: MouseDown, MouseWheel, MouseClick, MouseMove, MouseEnter, MouseLeave
mouse_wheel MOD = 0, X = 0, Y = 0, INCR = 0, POST = 0โ sends or posts (thePOSTflag) a simulated event to the system.MOD,X,Y, andINCRare the parameters passed to the notification callbacks. (and yes, the page literally says"MouseUp"for this one โ I'm not out here rewriting the source, bestie ๐ญ)
See also: MouseDown, MouseUp, MouseClick, MouseMove, MouseEnter, MouseLeave
nextโ returns the neighbor sibling widget, next up (above) in the Z-order โฌ๏ธ If there isn't one? you getundef.
See also: first, last, prev
next_tab FORWARD = 1โ returns the next widget in the list of sibling widgets, sorted by::tabOrder.FORWARDis the boolean lookup-direction flag. If nothing turns up, the first widget (or the last one, depending on theFORWARDflag) comes back instead. Only widgets with::tabStopset to1even get to participate in the scanning ๐
Also used by the internal keyboard navigation code.
See also: next_positional, tabOrder, tabStop, selectable
next_positional DELTA_X DELTA_Yโ bestie this one is doing spatial math for you ๐ซ It returns the sibling, the (grand-)child of a sibling, or the (grand-)child widget that matched best the direction specified by theDELTA_XandDELTA_Yintegers. Heads up tho: only one of these parameters may be zero, and the other parameter must be either1or-1. No vibes-based guessing allowed. Also used by the internal keyboard navigation code, so it's literally the main character of arrow-key movement.
See also: next_tab, origin
pack,packForget,packSlavesโ seePrima::Widget::pack๐place,placeForget,placeSlavesโ seePrima::Widget::place๐prevโ Returns the neighbor sibling widget, previous (below) in the Z-order. If none is found,undefis returned โ ghosted, no neighbors, we move on. ๐ป
See also: first, last, next
repaintโ Marks the whole widget area as'invalid', triggering the re-painting of the widget. It's giving "flag it and let the paint department handle it" โจ SeeGraphic content.
See also: validate_rect, get_invalid_rect, invalidate_rect, Paint, update_view, syncPaint
rect_bevel $CANVAS, @RECT, %OPTIONSโ Draws a rectangular area, similar to one produced by therect3dmethod, over@RECTwhich is a 4-integer tuple(X1,Y1,X2,Y2). Uses the values of the widget'slight3DColoranddark3DColorproperties โ so it matches the whole 3D aesthetic automatically, iconic ๐ซถ The following options are recognized:fill COLORโ if set, the area is filled withCOLOR, otherwise is left intactwidth INTEGERโ the width of the border in pixelsconcave BOOLEANโ if1, draws a concave area, or a bulged area otherwise
responsiveโ Returns the boolean flag indicating whether the widget and its owners have all the::enabledproperty value set1or not. Super useful for the fast check if the widget should respond to the user's actions โ like a vibe check before you even try ๐
See also: enabled
screen_to_client @OFFSETSโ Maps array of X and Y integer offsets from screen to widget coordinates. Returns the mappedOFFSETS. Coordinate glow-up, no cap โจ
See also: client_to_screen
scroll DELTA_X DELTA_Y %OPTIONSโ Scrolls the graphic context area byDELTA_XandDELTA_Ypixels. TheOPTIONSis a hash that may contain the following optional parameters:clipRect [X1, Y1, X2, Y2]โ the clipping area is confined by theX1,Y1,X2,Y2rectangle. If not specified, the clipping area covers the whole widget. Only the bits covered by theclipRectare affected. The bits scrolled from the outside of the rectangle to the inside are invalidated; the bits scrolled from the inside of the rectangle to the outside are not invalidated โ read that twice bestie, it's the whole plot twist ๐confineRect [X1, Y1, X2, Y2]โ the scrolling area is confined by theX1,Y1,X2,Y2rectangle. If not specified, the scrolling area covers the whole widget.withChildren BOOLEANโ if1, the scrolling affects the eventual children widgets so that they also change their positions toDELTA_XandDELTA_Y. The whole fam moves together ๐ซถ
Returns one of the following constants:
scr::Error - failure
scr::NoExpose - call resulted in no new exposed areas
scr::Expose - call resulted in new exposed areas, expect a repaint
๐จ Cannot be used inside the paint state. Not negotiable, it's literally not allowed in there.
See also: Paint, get_invalid_rect
selectโ Alias forselected(1)call ๐
See also: deselect, selected, Enter, Leave
send_to_backโ Sends the widget to the bottom of all other sibling widgets. It's giving "your seat is in the back row now" ๐ญ
See also: insert_behind, bring_to_front, ZOrderChanged, first, next, prev, last
showโ Sets the widget's::visibleproperty to1. The comeback arc we love to see ๐
See also: hide, visible, Show, Hide, showing, exposed
show_cursorโ Shows the cursor. Careful: if thehide_cursor()method was called more than once then theshow_cursorshould also be called as many times to show the cursor back. It's a counter thing, not a single toggle โ fr fr, keep track ๐ญ
See also: hide_cursor, cursorVisible
showingโ Returns the boolean value indicating whether the widget and its owners have all::visibleproperty set to1or not. So basically "is this thing actually on screen or just pretending" ๐ฆunlockโ Turns on the ability of a widget to re-paint itself. As many times thelock()method was called, as many times its counterpart, theunlock()method must be called to enable re-painting again. After the lastunlock()is called an implicitrepaint()call is issued. Returns the boolean success flag. Balanced energy only, bestie โ๏ธ
See also: lock, repaint, Paint, get_locked
update_viewโ If any parts of the widget were marked as'invalid'by either theinvalidate_rect(),scroll, orrepaint()calls, or by the exposure caused by the window movements, then thePaintnotification is immediately called. If no parts are invalid, no action is performed โ nothing to do, we rest ๐ค If the widget has the::syncPaintproperty set to1theupdate_view()is always a no-op call, so don't expect anything from it in that mode.
See also: invalidate_rect, get_invalid_rect, repaint, Paint, syncPaint, update_view
validate_rect X_LEFT_OFFSET Y_BOTTOM_OFFSET X_RIGHT_OFFSET Y_TOP_OFFSETโ Reverses the effect ofinvalidate_rect(), restoring the original,'valid'state of the widget area covered by the rectangular area passed. If the widget with previously invalid areas was wholly validated by this method, noPaintnotifications occur. It's the undo button of the invalidation world โจ
See also: invalidate_rect, get_invalid_rect, repaint, Paint, syncPaint, update_view
๐ Get-methods ๐
Getters!! The "just tell me the value already" squad, we love them ๐
get_default_fontโ Returns the default font for thePrima::Widgetclass.
See also: font
get_default_popup_fontโ Returns the default font for thePrima::Popupclass.
See also: font
get_invalid_rectโ Returns the rectangle encompassing the actual invalid region on the widget. If the widget doesn't need to be repainted, the(0,0,0,0)tuple is returned โ i.e. the "we're so clean" signal ๐ง
See also: validate_rect, invalidate_rect, repaint, Paint, syncPaint, update_view
get_handleโ Returns the system handle for the widget. The underlying-system lore ๐ฅ
See also: get_parent_handle, Window::get_client_handle
get_lockedโ Returns1if thelock()was called and all repaints are effectively blocked.
See also: lock, unlock
get_mouse_stateโ Returns a combination of themb::XXXconstants that reflects the currently pressed mouse buttons. Click click, we know what you're holding ๐ฑ๏ธ
See also: pointerPos, get_shift_state
get_parentโ Returns the widget that the caller widget boundaries get clipped to, or the application object if the caller widget is top-level or has theclipOwnerproperty set to1.
See also: clipOwner
get_parent_handleโ Returns the system handle for the parent of the widget, the window that belongs to another program. Returns0if the widget's owner and parent are in the same application and process space.
See also: get_handle, clipOwner
get_pointer_sizeโ Returns two integers, the width and height of the icon, that the system accepts as valid for the mouse pointer. If the sizes of the icon exceed or are inferior to the size the icon is then truncated or padded with transparency bits ( but not stretched ) โ no stretching allowed, the system said what it said ๐ โโ๏ธ Can be called with the class syntax as it returns the system-wide value.get_shift_stateโ Returns a combination of thekm::XXXconstants that reflects the currently pressed keyboard modifier buttons.
See also: get_shift_state
get_virtual_sizeโ Returns the virtual width and height of the widget. SeeGeometry, Implicit size regulations.
See also: width, height, size, growMode, Move, Size, sizeMax, sizeMin
get_widgetsโ Returns the list of the children widgets. The whole squad, assembled ๐ซถ
๐ Events ๐
Changeโ A generic notification, is used for thePrima::Widget's descendants; thePrima::Widgetclass itself neither calls nor uses the event. Designed to be called when an arbitrary major state of the widget is changed.Clickโ A generic notification, is used for thePrima::Widget's descendants;Prima::Widgetitself neither calls nor uses the event. Designed to be called when an arbitrary major action for the widget is called. (Yes, it's the sibling ofChangeโ same energy, different occasion โจ)Closeโ Triggered by thecan_close()andclose()functions. If the event flag is cleared during execution, these functions return the false value โ so you can literally veto the close, main character move ๐
See also: close, can_close
ColorChanged INDEXโ Called when one of the widget's color properties is changed, either by a direct property change or by the system.INDEXis one of theci::XXXconstants.
See also: colorIndex
Disableโ Triggered by a successfulenabled(0)call. The lights-off moment ๐ญ
See also: Enable, enabled, responsive
DragBegin CLIPBOARD, ACTION, MOD, X, Y, COUNTERPARTโ Triggered on the receiver widget when the mouse pointer with a DND object enters its screen boundaries.CLIPBOARDcontains the DND data,ACTIONis a combination of thednd::constants that reflect the actions the sender is ready to offer,MODis a combination of the modifier keys (kb::), andXandYare the coordinates where the mouse pointer has entered the widget. This event and the followingDragOverandDragEndevents occur only if the propertydndAwareis set either to1or if it matches the clipboard format that exists in theCLIPBOARD. NodndAware, no party ๐ช
COUNTERPART is set to the Prima DND sender widget if the session was initiated within the same program; is undef otherwise.
See also: Drag and Drop, DragOver, DragEnd
DragEnd CLIPBOARD, ACTION, MOD, X, Y, COUNTERPART, ANSWERโ Triggered on the receiver widget when the user either drops or cancels the DND session. In case of the canceled drop,CLIPBOARDis set toundefandACTIONto thednd::Noneconstant. On a successful drop, the input data are the same as inDragBeginwhile the output data are expected to be stored in the hashrefANSWER, if any. The following answers can be stored:allow BOOLEANโ is pre-set to1. If changed to0, a signal will be sent to the sender that the drop request is not accepted. Politely declining, we stan a boundary ๐action INTEGERโ adnd::constant (not a combination) to be returned to the sender with the action the receiver has accepted, if any.
COUNTERPART is set to the Prima DND sender widget if the session was initiated within the same program; is undef otherwise.
See also: Drag and Drop, DragBegin, DragOver
DragOver CLIPBOARD, ACTION, MOD, X, Y, COUNTERPART, ANSWERโ okay so this one fires on the received widget during a DND session, bestie. It gets sent repeatedly while the user drags the mouse pointer over the widget. The input data are same as inDragBegin, and output data go into the hashrefANSWER, if any. The following answers can be stored:allow BOOLEANโ pre-set to 1. If the event handler changes it to 0, a response gets sent to the sender saying a drop action cannot happen with the input or location provided.action INTEGERโ adnd::constant (not a combination) returned to the sender with the action the receiver is ready to accept, if any.pad X, Y, WIDTH, HEIGHTโ if set, tells the sender not to repeatDragOverevents that contain the same input data while the mouse pointer is within these geometrical limits.
COUNTERPART is the Prima DND sender widget, if the session is initiated within the same program.
DragQuery MOD, COUNTERPART, ANSWERโ triggered on a sender DND widget when thereโs a detected change in the mouse or modifier buttons, or when the user pressed theEscapekey to cancel the DND session. The combo of mouse and modifier buttons is stored in theMODinteger parameter. Thekm::Escapebit is set if theEscapekey is pressed.
It is up to the event handler to decide whether to continue the drag session or not. If it is decided not to continue, the $ANSWER->{allow} flag must be set to 0.
Additionally, the $ANSWER->{action} flag can be assigned a single dnd:: constant to counter-propose the action to the sender. The proposal will be typically based on the MOD value, f.ex. dnd::Move if the CTRL key was pressed.
Note: This action will only forward the change to the receiver on X11, but it is advised to implement it anyway for the sake of portability.
COUNTERPART is the Prima DND receiver widget, if the session is initiated within the same program.
See also: Drag and Drop, DragResponse
DragResponse ALLOW, ACTION, COUNTERPARTโ triggered on the sender DND widget when thereโs a detected change in the mouse or modifier buttons, or when the mouse was moved from one DND target to another. The sender event handler is then presented with the new input, collected from the interaction with the new target. There, theALLOWinteger parameter is set to a boolean value that shows whether the sender is allowed to drop data or not. TheACTIONis thednd::constant with the action the receiver has earlier agreed to accept, if any.
If the DND session was started without the option to update mouse pointers on this event, the event handler should update the pointer itself. It is not needed though to save and restore the mouse pointers before and after the DND session, the begin_drag method manages this.
COUNTERPART is the Prima DND receiver widget, if the session is initiated within the same program.
See also: Drag and Drop, dnd_start, begin_drag.
Enableโ triggered by a successfulenabled(1)call โจ
See also: Disable, enabled, responsive
Enterโ called when the widget receives the input focus. main character moment, honestly.
See also: Leave, focused, selected
FontChangedโ called when the widget font is changed either by the direct property change call or by the system.
See also: font, ColorChanged
Hideโ triggered by a successfulvisible(0)call.
See also: Show, visible, showing, exposed
Hint SHOW_FLAGโ called when the hint label is about to show or hide, depending on theSHOW_FLAGparameter. The show or hide action is not executed if the event flag is cleared in the event handler.
See also: showHint, ownerShowHint, hintVisible, ownerHint
KeyDown CODE, KEY, MOD, REPEATโ sent to the focused widget when the user presses a key.CODEcontains an eventual character code,KEYis one of thekb::XXXconstants, andMODis a combination of the modifier keys pressed when the event occurred (thekm::XXXconstants).REPEATis an integer with the number of how many times the key was pressed; usually, it is 1. (see::briefKeys).
The valid km:: constants are:
km::Shift
km::Ctrl
km::Alt
km::KeyPad
km::DeadKey
km::Unicode
The valid kb:: constants are grouped in several sets. Some codes are aliased, for example, kb::PgDn and kb::PageDown have the same value.
Modifier keys
kb::ShiftL kb::ShiftR kb::CtrlL kb::CtrlR
kb::AltL kb::AltR kb::MetaL kb::MetaR
kb::SuperL kb::SuperR kb::HyperL kb::HyperR
kb::CapsLock kb::NumLock kb::ScrollLock kb::ShiftLock
Keys with character code defined
kb::Backspace kb::Tab kb::Linefeed kb::Enter
kb::Return kb::Escape kb::Esc kb::Space
Function keys
kb::F1 .. kb::F30
kb::L1 .. kb::L10
kb::R1 .. kb::R10
Other
kb::Clear kb::Pause kb::SysRq kb::SysReq
kb::Delete kb::Home kb::Left kb::Up
kb::Right kb::Down kb::PgUp kb::Prior
kb::PageUp kb::PgDn kb::Next kb::PageDown
kb::End kb::Begin kb::Select kb::Print
kb::PrintScr kb::Execute kb::Insert kb::Undo
kb::Redo kb::Menu kb::Find kb::Cancel
kb::Help kb::Break kb::BackTab
See also: KeyUp, briefKeys, key_down, help, popup, tabOrder, tabStop, accelTable
KeyUp CODE, KEY, MODโ sent to the focused widget when the user releases a key.CODEcontains an eventual character code,KEYis one of thekb::XXXconstants, andMODis a combination of the modifier keys pressed when the event occurred (km::XXX).
See also: KeyDown, key_up
Leaveโ called when the input focus is removed from the widget.
See also: Enter, focused, selected
Menu MENU VAR_NAMEโ called before the user-navigated menu (pop-up or pull-down) is about to show another level of submenu on the screen.MENUis aPrima::AbstractMenudescendant, that is also a direct child to the widget.VAR_NAMEis the name of the menu item that is about to be shown.
Can be used for making dynamic changes in the menu structures, f.ex. enabling or disabling clipboard commands if there is data in the clipboard that can be pasted.
See also: popupItems
MouseClick BUTTON, MOD, X, Y, NTHโ called when the mouse click (a button is pressed, then released, within the system-defined interval of time) occurs in the widget area.BUTTONis one of themb::XXXconstants,MODis a combination of thekm::XXXconstants that reflects the pressed modifier keys during the event, and X and Y are the mouse pointer coordinates.NTHis an integer, set to 0 if it was a single click, and to 2 and up if it was a double (triple, etc etc) click.
The mb::XXX constants are:
mb::b1 or mb::Left
mb::b2 or mb::Middle
mb::b3 or mb::Right
mb::b4
mb::b5
mb::b6
mb::b7
mb::b8
See also: MouseDown, MouseUp, MouseWheel, MouseMove, MouseEnter, MouseLeave
MouseDown BUTTON, MOD, X, Yโ occurs when the user presses a mouse button on the widget.BUTTONis one of themb::XXXconstants,MODis a combination of thekm::XXXconstants that reflects the pressed modifier keys during the event, and X and Y are the mouse pointer coordinates.
See also: MouseUp, MouseClick, MouseWheel, MouseMove, MouseEnter, MouseLeave
MouseEnter MOD, X, Yโ occurs when the mouse pointer enters the area occupied by the widget.MODis a combination of thekm::XXXconstants that reflects the pressed modifier keys during the event, and X and Y are the mouse pointer coordinates.
See also: MouseDown, MouseUp, MouseClick, MouseWheel, MouseMove, MouseLeave
MouseLeaveโ occurs when the mouse pointer leaves the area occupied by the widget.
See also: MouseDown, MouseUp, MouseClick, MouseWheel, MouseMove, MouseEnter
MouseMove MOD, X, Yโ occurs when the mouse pointer moves over the widget.MODis a combination of thekm::XXXconstants that reflects the pressed modifier keys during the event, and X and Y are the mouse pointer coordinates.
See also: MouseDown, MouseUp, MouseClick, MouseWheel, MouseEnter, MouseLeave
MouseUp BUTTON, MOD, X, Yโ occurs when the user depresses a mouse button on the widget.BUTTONis one of themb::XXXconstants,MODis a combination of thekm::XXXconstants that reflects the pressed modifier keys during the event, X and Y are the mouse pointer coordinates.
See also: MouseDown, MouseClick, MouseWheel, MouseMove, MouseEnter, MouseLeave
MouseWheel MOD, X, Y, INCRโ occurs when the user rotates the mouse wheel on the widget.MODis a combination of thekm::XXXconstants that reflects the pressed modifier keys during the event,INCRis the wheel movement, scaled by 120. +120 is a step upwards, and -120 is a step downwards. Many of the consumer mice report the wheel moves with a resolution of 120, the gamer mice may report a better resolution. An event handler should treat the scroll values as INCR/120 per unit, for whatever the unit of movement might be, for example as lines of text, slider ticks, etc.
The event handle may use different units if some MOD keys are pressed. For example, the Prima::SpinEdit class has two different step and pageStep properties, and it uses the value of the pageStep property when the CTRL key is pressed and the value of the step property otherwise (see Prima::Sliders ).
See also: MouseDown, MouseUp, MouseClick, MouseMove, MouseEnter, MouseLeave
Move OLD_X, OLD_Y, NEW_X, NEW_Yโ triggered when the widget changes its position relative to its parent, either by one of the Prima::Widget methods or by the user.OLD_XandOLD_Yare the old coordinates of the widget,NEW_XandNEW_Yare the new ones. <butterfly>slay.</butterfly>
See also: Size, origin, growMode, centered, clipOwner
Paint CANVAS
okay so this one fires when the system calls for the refresh of the widget's graphic content. CANVAS is literally the widget itself, so use it to draw on (see Graphic content).
- See also:
repaint,syncPaint,get_invalid_rect,scroll,colorIndex,font
Popup BY_MOUSE, X, Y
bestie, this is called by the system when the user presses the key or the mouse combination defined for execution of a context pop-up menu. By default it executes the associated Prima::Popup object if it is present.
If the event flag is cleared in the event handler, then the pop-up menu request is denied and the popup is not shown. no cap, that's the whole vibe check right there.
- See also:
popup
Setup
This message is posted right after the Create notification and is delivered to widgets from inside the event loop. Prima::Widget does not use it for anything.
Show
Triggered by a successful visible(1) call.
- See also:
Show,visible,showing,exposed
Size OLD_WIDTH, OLD_HEIGHT, NEW_WIDTH, NEW_HEIGHT
Triggered when the widget changes its size, either by Prima::Widget methods or by the user. OLD_WIDTH and OLD_HEIGHT are the old sizes of the widget, and NEW_WIDTH and NEW_HEIGHT are the new ones.
- See also:
Move,origin,size,growMode,sizeMax,sizeMin,rect,clipOwner
SysHandle
Same as in Component, except that the following Widget properties can also trigger it:
clipOwnersyncPaintlayeredtransparent
Handling of this event is generally needed only if the program relies on the widget's system handle that is returned by the get_handle method.
TranslateAccel CODE, KEY, MOD
A distributed version of the KeyDown event. The event traverses all of the object tree that the widget that received the original KeyDown event belongs to. Once the event flag is cleared, the iteration stops.
Used by the widgets that need to react to the keyboard input even if not focused.
- See also:
KeyDown
ZOrderChanged
Triggered when the widget's stacking order ( Z-order ) is changed either by one of the Prima::Widget methods or by the user.
- See also:
bring_to_front,insert_behind,send_to_back
AUTHOR ๐
Dmitry Karasik, <dmitry@karasik.eu.org>.
SEE ALSO ๐ญ
Prima, Prima::Object, Prima::Drawable.
okay bestie, that's the whole page โ signing off from pod::Prima::Widget(3), perl v5.42.0 edition, dated 2024-08-20 ๐ซถ๐โจ periodt.
๐ฆ where this page comes from
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 ยท AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 ยท AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 ยท AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 ยท AGPL-3.0-only AND BSD-2-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms