Class ShortcutTrigger

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
AlternativeTrigger, KeyvalTrigger, MnemonicTrigger, NeverTrigger, ShortcutTrigger.ShortcutTrigger$Impl

@Generated("org.javagi.JavaGI") public abstract class ShortcutTrigger extends GObject

Tracks how a GtkShortcut can be activated.

To find out if a GtkShortcutTrigger triggers, you can call trigger(Event, boolean) on a GdkEvent.

GtkShortcutTriggers contain functions that allow easy presentation to end users as well as being printed for debugging.

All GtkShortcutTriggers are immutable, you can only specify their properties during construction. If you want to change a trigger, you have to replace it with a new one.

  • Constructor Details

    • ShortcutTrigger

      public ShortcutTrigger(MemorySegment address)
      Create a ShortcutTrigger instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ShortcutTrigger

      public ShortcutTrigger()
      Create a new ShortcutTrigger.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ShortcutTrigger class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ShortcutTrigger asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • parseString

      public static @Nullable ShortcutTrigger parseString(String string)

      Tries to parse the given string into a trigger.

      On success, the parsed trigger is returned. When parsing failed, null is returned.

      The accepted strings are:

      • never, for GtkNeverTrigger
      • a string parsed by gtk_accelerator_parse(), for a GtkKeyvalTrigger, e.g. <Control>C
      • underscore, followed by a single character, for GtkMnemonicTrigger, e.g. _l
      • two valid trigger strings, separated by a | character, for a GtkAlternativeTrigger: <Control>q|<Control>w

      Note that you will have to escape the < and > characters when specifying triggers in XML files, such as GtkBuilder ui files. Use &lt; instead of < and &gt; instead of >.

      Parameters:
      string - the string to parse
      Returns:
      a new GtkShortcutTrigger
    • compare

      public int compare(ShortcutTrigger trigger2)

      The types of this ShortcutTrigger and trigger2 are gconstpointer only to allow use of this function as a GCompareFunc.

      They must each be a GtkShortcutTrigger.

      Parameters:
      trigger2 - a GtkShortcutTrigger
      Returns:
      An integer less than, equal to, or greater than zero if this ShortcutTrigger is found, respectively, to be less than, to match, or be greater than trigger2.
    • equal

      public boolean equal(ShortcutTrigger trigger2)

      Checks if this ShortcutTrigger and trigger2 trigger under the same conditions.

      The types of one and two are gconstpointer only to allow use of this function with GHashTable. They must each be a GtkShortcutTrigger.

      Parameters:
      trigger2 - a GtkShortcutTrigger
      Returns:
      true if this ShortcutTrigger and trigger2 are equal
    • hash

      public int hash()

      Generates a hash value for a GtkShortcutTrigger.

      The output of this function is guaranteed to be the same for a given value only per-process. It may change between different processor architectures or even different versions of GTK. Do not use this function as a basis for building protocols or file formats.

      The types of this ShortcutTrigger is gconstpointer only to allow use of this function with GHashTable. They must each be a GtkShortcutTrigger.

      Returns:
      a hash value corresponding to this ShortcutTrigger
    • print

      public void print(String string)

      Prints the given trigger into a string for the developer. This is meant for debugging and logging.

      The form of the representation may change at any time and is not guaranteed to stay identical.

      Parameters:
      string - a GString to print into
    • printLabel

      public boolean printLabel(Display display, String string)

      Prints the given trigger into a string.

      This function is returning a translated string for presentation to end users for example in menu items or in help texts.

      The display in use may influence the resulting string in various forms, such as resolving hardware keycodes or by causing display-specific modifier names.

      The form of the representation may change at any time and is not guaranteed to stay identical.

      Parameters:
      display - GdkDisplay to print for
      string - a GString to print into
      Returns:
      true if something was printed or false if the trigger did not have a textual representation suitable for end users.
    • toLabel

      public String toLabel(Display display)

      Gets textual representation for the given trigger.

      This function is returning a translated string for presentation to end users for example in menu items or in help texts.

      The display in use may influence the resulting string in various forms, such as resolving hardware keycodes or by causing display-specific modifier names.

      The form of the representation may change at any time and is not guaranteed to stay identical.

      Parameters:
      display - GdkDisplay to print for
      Returns:
      a new string
    • toString

      public String toString()

      Prints the given trigger into a human-readable string.

      This is a small wrapper around print(String) to help when debugging.

      Overrides:
      toString in class Object
      Returns:
      a new string
    • trigger

      public KeyMatch trigger(Event event, boolean enableMnemonics)
      Checks if the given event triggers self.
      Parameters:
      event - the event to check
      enableMnemonics - true if mnemonics should trigger. Usually the value of this property is determined by checking that the passed in event is a Key event and has the right modifiers set.
      Returns:
      Whether the event triggered the shortcut