# :stopdoc: # This file is automatically generated by the WXRuby3 documentation # generator. Do not alter this file. # :startdoc: module Wx # Common base class for single line text entry fields. # # This class is not a control itself, as it doesn't derive from {Wx::Window}. Instead it is used as a base class by other controls, notably {Wx::TextCtrl} and {Wx::ComboBox} and gathers the methods common to both of them. # # Category: {Wx::Controls} # @see Wx::TextCtrl # @see Wx::ComboBox # # # # @note In wxRuby this is a mixin module instead of a (base) class. module TextEntry # @overload set_margins(pt) # Attempts to set the control margins. # # When margins are given as {Wx::Point}, x indicates the left and y the top margin. Use -1 to indicate that an existing value should be used. # true if setting of all requested margins was successful. # @param pt [Array(Integer, Integer), Wx::Point] # @return [Boolean] # @overload set_margins(left, top=-1) # Attempts to set the control margins. # # When margins are given as {Wx::Point}, x indicates the left and y the top margin. Use -1 to indicate that an existing value should be used. # true if setting of all requested margins was successful. # @param left [Integer] # @param top [Integer] # @return [Boolean] def set_margins(*args) end alias_method :margins=, :set_margins # Appends the text to the end of the text control. # #
After the text is appended, the insertion point will be at the end of the text control. If this behaviour is not desired, the programmer should use {Wx::TextEntry#get_insertion_point} and {Wx::TextEntry#set_insertion_point}. #
#Wx::/textcompleter.h
in order to define your class inheriting from {Wx::TextCompleter}.
#
# true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform.
# @see Wx::TextCompleter
# @param completer [Wx::TextCompleter] The object to be used for generating completions if non-NULL. If it is NULL, auto-completion is disabled. The {Wx::TextEntry} object takes ownership of this pointer and will delete it in any case (i.e. even if this method returns false).
# @return [Boolean]
def auto_complete(*args) end
# Call this function to enable auto-completion of the text typed in a single-line text control using all valid file system paths.
#
# Notice that currently this function is only implemented in WXMSW port and does nothing under the other platforms.
#
# true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform.
# @see Wx::TextEntry#auto_complete
# @return [Boolean]
def auto_complete_file_names; end
# Call this function to enable auto-completion of the text using the file system directories.
#
# Unlike {Wx::TextEntry#auto_complete_file_names} which completes both file names and directories, this function only completes the directory names.
# Notice that currently this function is only implemented in WXMSW port and does nothing under the other platforms.
#
# true if the auto-completion was enabled or false if the operation failed, typically because auto-completion is not supported by the current platform.
# @see Wx::TextEntry#auto_complete
# @return [Boolean]
def auto_complete_directories; end
# Returns true if the selection can be copied to the clipboard.
# @return [Boolean]
def can_copy; end
alias_method :can_copy?, :can_copy
# Returns true if the selection can be cut to the clipboard.
# @return [Boolean]
def can_cut; end
alias_method :can_cut?, :can_cut
# Returns true if the contents of the clipboard can be pasted into the text control.
#
# On some platforms (Motif, GTK) this is an approximation and returns true if the control is editable, false otherwise.
# @return [Boolean]
def can_paste; end
alias_method :can_paste?, :can_paste
# Returns true if there is a redo facility available and the last operation can be redone.
# @return [Boolean]
def can_redo; end
alias_method :can_redo?, :can_redo
# Returns true if there is an undo facility available and the last operation can be undone.
# @return [Boolean]
def can_undo; end
alias_method :can_undo?, :can_undo
# Sets the new text control value.
#
# It also marks the control as not-modified which means that IsModified() would return false immediately after the call to {Wx::TextEntry#change_value}.
# The insertion point is set to the start of the control (i.e. position 0) by this function.
# This functions does not generate the {Wx::EVT_TEXT} event but otherwise is identical to {Wx::TextEntry#set_value}.
# See User Generated Events vs Programmatically Generated Events for more information.
# @param value [String] The new value to set. It may contain newline characters if the text control is multi-line.
# @return [void]
def change_value(value) end
# Clears the text in the control.
#
# Note that this function will generate a {Wx::EVT_TEXT} event, i.e. its effect is identical to calling SetValue("").
# @return [void]
def clear; end
# Copies the selected text to the clipboard.
# @return [void]
def copy; end
# Copies the selected text to the clipboard and removes it from the control.
# @return [void]
def cut; end
# Convert all text entered into the control to upper case.
#
# Call this method to ensure that all text entered into the control is converted on the fly to upper case. If the control is not empty, its existing contents is also converted to upper case.
# @return [void]
def force_upper; end
# Returns the insertion point, or cursor, position.
#
# This is defined as the zero based index of the character position to the right of the insertion point. For example, if the insertion point is at the end of the single-line text control, it is equal to {Wx::TextEntry#get_last_position}.
# Notice that insertion position is, in general, different from the index of the character the cursor position at in the string returned by {Wx::TextEntry#get_value}. While this is always the case for the single line controls, multi-line controls can use two characters "\\r\\n"
as line separator (this is notably the case under MSW) meaning that indices in the control and its string value are offset by 1 for every line.
# Hence to correctly get the character at the current cursor position, taking into account that there can be none if the cursor is at the end of the string, you could do the following:
#
# ```ruby
# def get_current_char(txt_ctrl)
# pos = txt_ctrl.get_insertion_point
# return '' if pos == txt_ctrl.get_last_position
#
# txt_ctrl.get_range(pos, pos + 1)
# end
# ```
# @return [Integer]
def get_insertion_point; end
alias_method :insertion_point, :get_insertion_point
# Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control.
# @return [Wx::TextPos]
def get_last_position; end
alias_method :last_position, :get_last_position
# Returns the string containing the text starting in the positions from and up to to in the control.
#
# The positions must have been returned by another {Wx::TextCtrl} method. Please note that the positions in a multiline {Wx::TextCtrl} do not correspond to the indices in the string returned by {Wx::TextEntry#get_value} because of the different new line representations (CR or CR LF) and so this method should be used to obtain the correct results instead of extracting parts of the entire value. It may also be more efficient, especially if the control contains a lot of data.
# @param from [Integer]
# @param to [Integer]
# @return [String]
def get_range(from, to) end
alias_method :range, :get_range
# Gets the current selection span.
#
# If the returned values are equal, there was no selection. Please note that the indices returned may be used with the other {Wx::TextCtrl} methods but don't necessarily represent the correct indices into the string returned by {Wx::TextEntry#get_value} for multiline controls under Windows (at least,) you should use {Wx::TextEntry#get_string_selection} to get the selected text.
# @return [Array(Integer,Integer)]
def get_selection; end
alias_method :selection, :get_selection
# Gets the text currently selected in the control.
#
# If there is no selection, the returned string is empty.
# @return [String]
def get_string_selection; end
alias_method :string_selection, :get_string_selection
# Gets the contents of the control.
#
# Notice that for a multiline text control, the lines will be separated by (Unix-style) \n
characters, even under Windows where they are separated by a \r\n
sequence in the native control.
# @return [String]
def get_value; end
alias_method :value, :get_value
# Returns true if the controls contents may be edited by user (note that it always can be changed by the program).
#
# In other words, this functions returns true if the control hasn't been put in read-only mode by a previous call to {Wx::TextEntry#set_editable}.
# @return [Boolean]
def is_editable; end
alias_method :editable?, :is_editable
# Returns true if the control is currently empty.
#
# This is the same as Wx::TextEntry#get_value
.empty() but can be much more efficient for the multiline controls containing big amounts of text.
# @return [Boolean]
def is_empty; end
alias_method :empty?, :is_empty
# Pastes text from the clipboard to the text item.
# @return [void]
def paste; end
# If there is a redo facility and the last operation can be redone, redoes the last operation.
#
# Does nothing if there is no redo facility.
# @return [void]
def redo_; end
# Removes the text starting at the first given position up to (but not including) the character at the last position.
#
# This function puts the current insertion point position at to as a side effect.
# @param from [Integer] The first position.
# @param to [Integer] The last position.
# @return [void]
def remove(from, to) end
# Replaces the text starting at the first position up to (but not including) the character at the last position with the given text.
#
# This function puts the current insertion point position at to as a side effect.
# @param from [Integer] The first position.
# @param to [Integer] The last position.
# @param value [String] The value to replace the existing text with.
# @return [void]
def replace(from, to, value) end
# Makes the text item editable or read-only, overriding the {Wx::TE_READONLY} flag.
#
#
# @see Wx::TextEntry#is_editable
# @param editable [Boolean] If true, the control is editable. If false, the control is read-only.
# @return [void]
def set_editable(editable) end
alias_method :editable=, :set_editable
# Sets the insertion point at the given position.
# @param pos [Integer] Position to set, in the range from 0 to {Wx::TextEntry#get_last_position} inclusive.
# @return [void]
def set_insertion_point(pos) end
alias_method :insertion_point=, :set_insertion_point
# Sets the insertion point at the end of the text control.
#
# This is equivalent to calling {Wx::TextCtrl#set_insertion_point} with {Wx::TextCtrl#get_last_position} argument.
# @return [void]
def set_insertion_point_end; end
# This function sets the maximum number of characters the user can enter into the control.
#
# In other words, it allows limiting the text value length to len not counting the terminating NUL character.
# If len is 0, the previously set max length limit, if any, is discarded and the user may enter as much text as the underlying native text control widget supports (typically at least 32Kb). If the user tries to enter more characters into the text control when it already is filled up to the maximal length, a {Wx::EVT_TEXT_MAXLEN} event is sent to notify the program about it (giving it the possibility to show an explanatory message, for example) and the extra input is discarded.
# Note that in WXGTK this function may only be used with single line text controls.
# @param len [Integer]
# @return [void]
def set_max_length(len) end
alias_method :max_length=, :set_max_length
# Selects the text starting at the first position up to (but not including) the character at the last position.
#
# If both parameters are equal to -1 all text in the control is selected.
# Notice that the insertion point will be moved to from by this function.
# @see Wx::TextEntry#select_all
# @param from [Integer] The first position.
# @param to [Integer] The last position.
# @return [void]
def set_selection(from, to) end
# Selects all text in the control.
#
#
# @see Wx::TextEntry#set_selection
# @return [void]
def select_all; end
# Deselects selected text in the control.
# @return [void]
def select_none; end
# Sets a hint shown in an empty unfocused text control.
#
# The hints are usually used to indicate to the user what is supposed to be entered into the given entry field, e.g. a common use of them is to show an explanation of what can be entered in a {Wx::SearchCtrl}.
# The hint is shown (usually greyed out) for an empty control until it gets focus and is shown again if the control loses it and remains empty. It won't be shown once the control has a non-empty value, although it will be shown again if the control contents is cleared. Because of this, it generally only makes sense to use hints with the controls which are initially empty.
# Notice that hints are known as cue banners under MSW or placeholder strings under macOS.
#
# Currently implemented natively on Windows (Vista and later only), macOS and GTK+ (3.2 and later). #
#Hints can be used for single line text controls under all platforms, but only MSW and GTK+ 2 support them for multi-line text controls, they are ignored for them under the other platforms. #
#If given margin cannot be accurately determined, its value will be set to -1. On some platforms you cannot obtain valid margin values until you have called {Wx::TextEntry#set_margins}. #
#Newlines in the text string are the only control characters allowed, and they will cause appropriate line breaks. See operator<<() and {Wx::TextEntry#append_text} for more convenient ways of writing to the window. After the write operation, the insertion point will be at the end of the inserted text, so subsequent write operations will be appended. To append text after the user may have interacted with the control, call {Wx::TextCtrl#set_insertion_point_end} before writing. #
#