package ocgtk

  1. Overview
  2. Docs
OCaml bindings for GTK 4

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1-preview2.tar.gz
sha256=4e50fdb5093136a10fc8ffbe388e44cbcb70d52f8afdd48863ec7e22580ff054

doc/ocgtk.gtk/Ocgtk_gtk/Gtk/Wrappers/Editable/index.html

Module Wrappers.Editable

type t = [ `editable ] Gobject.obj
val from_gobject : 'a Gobject.obj -> t
val set_width_chars : t -> int -> unit

Changes the size request of the editable to be about the right size for @n_chars characters.

Note that it changes the size request, the size can still be affected by how you pack the widget into containers. If @n_chars is -1, the size reverts to the default size.

val set_text : t -> string -> unit

Sets the text in the editable to the given value.

This is replacing the current contents.

val set_position : t -> int -> unit

Sets the cursor position in the editable to the given value.

The cursor is displayed before the character with the given (base 0) index in the contents of the editable. The value must be less than or equal to the number of characters in the editable. A value of -1 indicates that the position should be set after the last character of the editable. Note that @position is in characters, not in bytes.

val set_max_width_chars : t -> int -> unit

Sets the desired maximum width in characters of @editable.

val set_enable_undo : t -> bool -> unit

If enabled, changes to @editable will be saved for undo/redo actions.

This results in an additional copy of text changes and are not stored in secure memory. As such, undo is forcefully disabled when property@Gtk.Text:visibility is set to %FALSE.

val set_editable : t -> bool -> unit

Determines if the user can edit the text in the editable widget.

val set_alignment : t -> float -> unit

Sets the alignment for the contents of the editable.

This controls the horizontal positioning of the contents when the displayed text is shorter than the width of the editable.

val select_region : t -> int -> int -> unit

Selects a region of text.

The characters that are selected are those characters at positions from @start_pos up to, but not including @end_pos. If @end_pos is negative, then the characters selected are those characters from @start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

val insert_text : t -> string -> int -> int -> unit

Inserts @length bytes of @text into the contents of the widget, at position @position.

Note that the position is in characters, not in bytes. The function updates @position to point after the newly inserted text.

val init_delegate : t -> unit

Sets up a delegate for `GtkEditable`.

This is assuming that the get_delegate vfunc in the `GtkEditable` interface has been set up for the @editable's type.

This is a helper function that should be called in instance init, after creating the delegate object.

val get_width_chars : t -> int

Gets the number of characters of space reserved for the contents of the editable.

val get_text : t -> string

Retrieves the contents of @editable.

The returned string is owned by GTK and must not be modified or freed.

val get_selection_bounds : t -> bool * int * int

Retrieves the selection bound of the editable.

@start_pos will be filled with the start of the selection and @end_pos with end. If no text was selected both will be identical and %FALSE will be returned.

Note that positions are specified in characters, not bytes.

val get_position : t -> int

Retrieves the current position of the cursor relative to the start of the content of the editable.

Note that this position is in characters, not in bytes.

val get_max_width_chars : t -> int

Retrieves the desired maximum width of @editable, in characters.

val get_enable_undo : t -> bool

Gets if undo/redo actions are enabled for @editable

val get_editable : t -> bool

Retrieves whether @editable is editable.

val get_delegate : t -> t option

Gets the `GtkEditable` that @editable is delegating its implementation to.

Typically, the delegate is a class@Gtk.Text widget.

val get_chars : t -> int -> int -> string

Retrieves a sequence of characters.

The characters that are retrieved are those characters at positions from @start_pos up to, but not including @end_pos. If @end_pos is negative, then the characters retrieved are those characters from @start_pos to the end of the text.

Note that positions are specified in characters, not bytes.

val get_alignment : t -> float

Gets the alignment of the editable.

val finish_delegate : t -> unit

Undoes the setup done by method@Gtk.Editable.init_delegate.

This is a helper function that should be called from dispose, before removing the delegate object.

val delete_text : t -> int -> int -> unit

Deletes a sequence of characters.

The characters that are deleted are those characters at positions from @start_pos up to, but not including @end_pos. If @end_pos is negative, then the characters deleted are those from @start_pos to the end of the text.

Note that the positions are specified in characters, not bytes.

val delete_selection : t -> unit

Deletes the currently selected text of the editable.

This call doesn’t do anything if there is no selected text.

val delegate_get_accessible_platform_state : t -> Gtk_enums.accessibleplatformstate -> bool

Retrieves the accessible platform state from the editable delegate.

This is an helper function to retrieve the accessible state for `GtkEditable` interface implementations using a delegate pattern.

You should call this function in your editable widget implementation of the vfunc@Gtk.Accessible.get_platform_state virtual function, for instance:

```c static void accessible_interface_init (GtkAccessibleInterface *iface) iface->get_platform_state = your_editable_get_accessible_platform_state;

static gboolean your_editable_get_accessible_platform_state (GtkAccessible *accessible, GtkAccessiblePlatformState state) return gtk_editable_delegate_get_accessible_platform_state (GTK_EDITABLE (accessible), state); ```

val get_cursor_position : t -> int

Get property: cursor-position

val get_selection_bound : t -> int

Get property: selection-bound

val get_xalign : t -> float

Get property: xalign

val set_xalign : t -> float -> unit

Set property: xalign

val on_changed : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_delete_text : ?after:bool -> t -> callback:(start_pos:int -> end_pos:int -> unit) -> Gobject.Signal.handler_id