Package ch.bailu.gtk.gtk
Klasse Popover
- Alle implementierten Schnittstellen:
PointerInterface
- Bekannte direkte Unterklassen:
EmojiChooser
,PopoverMenu
Presents a bubble-like popup.
<picture>
<source srcset="popover-dark.png" media="(prefers-color-scheme: dark)">
<img alt="An example GtkPopover" src="popover.png">
</picture>
It is primarily meant to provide context-dependent information
or options. Popovers are attached to a parent widget. By default,
they point to the whole widget area, although this behavior can be
changed with [method@Gtk.Popover.set_pointing_to].
The position of a popover relative to the widget it is attached to
can also be changed with [method@Gtk.Popover.set_position]
By default, `GtkPopover` performs a grab, in order to ensure input
events get redirected to it while it is shown, and also so the popover
is dismissed in the expected situations (clicks outside the popover,
or the Escape key being pressed). If no such modal behavior is desired
on a popover, [method@Gtk.Popover.set_autohide] may be called on it to
tweak its behavior.
## GtkPopover as menu replacement
`GtkPopover` is often used to replace menus. The best way to do this
is to use the [class@Gtk.PopoverMenu] subclass which supports being
populated from a `GMenuModel` with [ctor@Gtk.PopoverMenu.new_from_model].
```xml
<section>
<attribute name="display-hint">horizontal-buttons</attribute>
<item>
<attribute name="label">Cut</attribute>
<attribute name="action">app.cut</attribute>
<attribute name="verb-icon">edit-cut-symbolic</attribute>
</item>
<item>
<attribute name="label">Copy</attribute>
<attribute name="action">app.copy</attribute>
<attribute name="verb-icon">edit-copy-symbolic</attribute>
</item>
<item>
<attribute name="label">Paste</attribute>
<attribute name="action">app.paste</attribute>
<attribute name="verb-icon">edit-paste-symbolic</attribute>
</item>
</section>
```
# Shortcuts and Gestures
`GtkPopover` supports the following keyboard shortcuts:
- <kbd>Escape</kbd> closes the popover.
- <kbd>Alt</kbd> makes the mnemonics visible.
The following signals have default keybindings:
- [signal@Gtk.Popover::activate-default]
# CSS nodes
```
popover.background[.menu]
├── arrow
╰── contents
╰── <child>
```
`GtkPopover` has a main node with name `popover`, an arrow with name `arrow`,
and another node for the content named `contents`. The `popover` node always
gets the `.background` style class. It also gets the `.menu` style class
if the popover is menu-like, e.g. is a [class@Gtk.PopoverMenu].
Particular uses of `GtkPopover`, such as touch selection popups or
magnifiers in `GtkEntry` or `GtkTextView` get style classes like
`.touch-selection` or `.magnifier` to differentiate from plain popovers.
When styling a popover directly, the `popover` node should usually
not have any background. The visible part of the popover can have
a shadow. To specify it in CSS, set the box-shadow of the `contents` node.
Note that, in order to accomplish appropriate arrow visuals, `GtkPopover`
uses custom drawing for the `arrow` node. This makes it possible for the
arrow to change its shape dynamically, but it also limits the possibilities
of styling it using CSS. In particular, the `arrow` gets drawn over the
`content` node's border and shadow, so they look like one shape, which
means that the border width of the `content` node and the `arrow` node should
be the same. The arrow also does not support any border shape other than
solid, no border-radius, only one border width (border-bottom-width is
used) and no box-shadow.
<picture>
<source srcset="popover-dark.png" media="(prefers-color-scheme: dark)">
<img alt="An example GtkPopover" src="popover.png">
</picture>
It is primarily meant to provide context-dependent information
or options. Popovers are attached to a parent widget. By default,
they point to the whole widget area, although this behavior can be
changed with [method@Gtk.Popover.set_pointing_to].
The position of a popover relative to the widget it is attached to
can also be changed with [method@Gtk.Popover.set_position]
By default, `GtkPopover` performs a grab, in order to ensure input
events get redirected to it while it is shown, and also so the popover
is dismissed in the expected situations (clicks outside the popover,
or the Escape key being pressed). If no such modal behavior is desired
on a popover, [method@Gtk.Popover.set_autohide] may be called on it to
tweak its behavior.
## GtkPopover as menu replacement
`GtkPopover` is often used to replace menus. The best way to do this
is to use the [class@Gtk.PopoverMenu] subclass which supports being
populated from a `GMenuModel` with [ctor@Gtk.PopoverMenu.new_from_model].
```xml
<section>
<attribute name="display-hint">horizontal-buttons</attribute>
<item>
<attribute name="label">Cut</attribute>
<attribute name="action">app.cut</attribute>
<attribute name="verb-icon">edit-cut-symbolic</attribute>
</item>
<item>
<attribute name="label">Copy</attribute>
<attribute name="action">app.copy</attribute>
<attribute name="verb-icon">edit-copy-symbolic</attribute>
</item>
<item>
<attribute name="label">Paste</attribute>
<attribute name="action">app.paste</attribute>
<attribute name="verb-icon">edit-paste-symbolic</attribute>
</item>
</section>
```
# Shortcuts and Gestures
`GtkPopover` supports the following keyboard shortcuts:
- <kbd>Escape</kbd> closes the popover.
- <kbd>Alt</kbd> makes the mnemonics visible.
The following signals have default keybindings:
- [signal@Gtk.Popover::activate-default]
# CSS nodes
```
popover.background[.menu]
├── arrow
╰── contents
╰── <child>
```
`GtkPopover` has a main node with name `popover`, an arrow with name `arrow`,
and another node for the content named `contents`. The `popover` node always
gets the `.background` style class. It also gets the `.menu` style class
if the popover is menu-like, e.g. is a [class@Gtk.PopoverMenu].
Particular uses of `GtkPopover`, such as touch selection popups or
magnifiers in `GtkEntry` or `GtkTextView` get style classes like
`.touch-selection` or `.magnifier` to differentiate from plain popovers.
When styling a popover directly, the `popover` node should usually
not have any background. The visible part of the popover can have
a shadow. To specify it in CSS, set the box-shadow of the `contents` node.
Note that, in order to accomplish appropriate arrow visuals, `GtkPopover`
uses custom drawing for the `arrow` node. This makes it possible for the
arrow to change its shape dynamically, but it also limits the possibilities
of styling it using CSS. In particular, the `arrow` gets drawn over the
`content` node's border and shadow, so they look like one shape, which
means that the border width of the `content` node and the `arrow` node should
be the same. The arrow also does not support any border shape other than
solid, no border-radius, only one border width (border-bottom-width is
used) and no box-shadow.
-
Verschachtelte Klassen - Übersicht
Verschachtelte KlassenModifizierer und TypKlasseBeschreibungstatic interface
static interface
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Feldübersicht
FelderVon Klasse geerbte Felder ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Von Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungImplements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.asNative()
Implements interfaceNative
.Implements interfaceShortcutManager
.boolean
Returns whether the popover is modal.boolean
Returns whether the popover will close after a modal child is closed.getChild()
Gets the child widget of @popover.static ClassHandler
boolean
Gets whether this popover is showing an arrow
pointing at the widget that it is relative to.static int
boolean
Gets whether mnemonics are visible.void
Gets the offset previous set with [method@Gtk.Popover.set_offset()].static long
static TypeSystem.TypeSize
boolean
getPointingTo
(Rectangle rect) Gets the rectangle that the popover points to.int
Returns the preferred position of @popover.static long
static TypeSystem.TypeSize
Connect to signal "activate-default".onClosed
(Popover.OnClosed signal) Connect to signal "closed".void
popdown()
Pops @popover down.void
popup()
Pops @popover up.void
present()
Allocate a size for the `GtkPopover`.void
setAutohide
(boolean autohide) Sets whether @popover is modal.void
setCascadePopdown
(boolean cascade_popdown) If @cascade_popdown is %TRUE, the popover will be
closed when a child modal popover is closed.void
Sets the child widget of @popover.void
setDefaultWidget
(Widget widget) Sets the default widget of a `GtkPopover`.void
setHasArrow
(boolean has_arrow) Sets whether this popover should draw an arrow
pointing at the widget it is relative to.void
setMnemonicsVisible
(boolean mnemonics_visible) Sets whether mnemonics should be visible.void
setOffset
(int x_offset, int y_offset) Sets the offset to use when calculating the position
of the popover.void
setPointingTo
(Rectangle rect) Sets the rectangle that @popover points to.void
setPosition
(int position) Sets the preferred position for @popover to appear.Von Klasse geerbte Methoden ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrProperty
Von Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Von Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Von Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Von Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Von Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Felddetails
-
SIGNAL_ON_ACTIVATE_DEFAULT
- Siehe auch:
-
SIGNAL_ON_CLOSED
- Siehe auch:
-
-
Konstruktordetails
-
Popover
-
Popover
public Popover()Creates a new `GtkPopover`.
-
-
Methodendetails
-
getClassHandler
-
getAutohide
public boolean getAutohide()Returns whether the popover is modal.
See [method@Gtk.Popover.set_autohide] for the
implications of this.- Gibt zurück:
- %TRUE if @popover is modal
-
getCascadePopdown
public boolean getCascadePopdown()Returns whether the popover will close after a modal child is closed.- Gibt zurück:
- %TRUE if @popover will close after a modal child.
-
getChild
Gets the child widget of @popover.- Gibt zurück:
- the child widget of @popover
-
getHasArrow
public boolean getHasArrow()Gets whether this popover is showing an arrow
pointing at the widget that it is relative to.- Gibt zurück:
- whether the popover has an arrow
-
getMnemonicsVisible
public boolean getMnemonicsVisible()Gets whether mnemonics are visible.- Gibt zurück:
- %TRUE if mnemonics are supposed to be visible in this popover
-
getOffset
Gets the offset previous set with [method@Gtk.Popover.set_offset()].- Parameter:
x_offset
- a location for the x_offsety_offset
- a location for the y_offset
-
getPointingTo
Gets the rectangle that the popover points to.
If a rectangle to point to has been set, this function will
return %TRUE and fill in @rect with such rectangle, otherwise
it will return %FALSE and fill in @rect with the parent
widget coordinates.- Parameter:
rect
- location to store the rectangle- Gibt zurück:
- %TRUE if a rectangle to point to was set.
-
getPosition
public int getPosition()Returns the preferred position of @popover.- Gibt zurück:
- The preferred position.
-
popdown
public void popdown()Pops @popover down.
This may have the side-effect of closing a parent popover
as well. See [property@Gtk.Popover:cascade-popdown]. -
popup
public void popup()Pops @popover up. -
present
public void present()Allocate a size for the `GtkPopover`.
This function needs to be called in size-allocate by widgets
who have a `GtkPopover` as child. When using a layout manager,
this is happening automatically.
To make a popover appear on screen, use [method@Gtk.Popover.popup]. -
setAutohide
public void setAutohide(boolean autohide) Sets whether @popover is modal.
A modal popover will grab the keyboard focus on it when being
displayed. Focus will wrap around within the popover. Clicking
outside the popover area or pressing Esc will dismiss the popover.
Called this function on an already showing popup with a new
autohide value different from the current one, will cause the
popup to be hidden.- Parameter:
autohide
- %TRUE to dismiss the popover on outside clicks
-
setCascadePopdown
public void setCascadePopdown(boolean cascade_popdown) If @cascade_popdown is %TRUE, the popover will be
closed when a child modal popover is closed.
If %FALSE, @popover will stay visible.- Parameter:
cascade_popdown
- %TRUE if the popover should follow a child closing
-
setChild
Sets the child widget of @popover.- Parameter:
child
- the child widget
-
setDefaultWidget
Sets the default widget of a `GtkPopover`.
The default widget is the widget that’s activated when the user
presses Enter in a dialog (for example). This function sets or
unsets the default widget for a `GtkPopover`.- Parameter:
widget
- a child widget of @popover to set as the default, or %NULL to unset the default widget for the popover
-
setHasArrow
public void setHasArrow(boolean has_arrow) Sets whether this popover should draw an arrow
pointing at the widget it is relative to.- Parameter:
has_arrow
- %TRUE to draw an arrow
-
setMnemonicsVisible
public void setMnemonicsVisible(boolean mnemonics_visible) Sets whether mnemonics should be visible.- Parameter:
mnemonics_visible
- the new value
-
setOffset
public void setOffset(int x_offset, int y_offset) Sets the offset to use when calculating the position
of the popover.
These values are used when preparing the [struct@Gdk.PopupLayout]
for positioning the popover.- Parameter:
x_offset
- the x offset to adjust the position byy_offset
- the y offset to adjust the position by
-
setPointingTo
Sets the rectangle that @popover points to.
This is in the coordinate space of the @popover parent.- Parameter:
rect
- rectangle to point to
-
setPosition
public void setPosition(int position) Sets the preferred position for @popover to appear.
If the @popover is currently visible, it will be immediately
updated.
This preference will be respected where possible, although
on lack of space (eg. if close to the window edges), the
`GtkPopover` may choose to appear on the opposite side.- Parameter:
position
- preferred popover position
-
onActivateDefault
Connect to signal "activate-default".
SeePopover.OnActivateDefault.onActivateDefault()
for signal description.
FieldSIGNAL_ON_ACTIVATE_DEFAULT
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onClosed
Connect to signal "closed".
SeePopover.OnClosed.onClosed()
for signal description.
FieldSIGNAL_ON_CLOSED
contains original signal name and can be used as resource reference.- Parameter:
signal
- callback function (lambda).- Gibt zurück:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Setzt außer Kraft:
asAccessible
in KlasseWidget
- Gibt zurück:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Setzt außer Kraft:
asBuildable
in KlasseWidget
- Gibt zurück:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Setzt außer Kraft:
asConstraintTarget
in KlasseWidget
- Gibt zurück:
ConstraintTarget
-
asNative
Implements interfaceNative
. Call this to get access to interface functions.- Gibt zurück:
Native
-
asShortcutManager
Implements interfaceShortcutManager
. Call this to get access to interface functions.- Gibt zurück:
ShortcutManager
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-