Class: Wx::TextCtrl
- Includes:
- TextEntry
- Defined in:
- lib/wx/doc/gen/text_ctrl.rb,
lib/wx/doc/textctrl.rb
Overview
A text control allows text to be displayed and edited.
It may be single line or multi-line. Notice that a lot of methods of the text controls are found in the base TextEntry class which is a common base class for TextCtrl and other controls using a single line text entry field (e.g. ComboBox).
Styles
This class supports the following styles:
-
TE_PROCESS_ENTER: The control will generate the event EVT_TEXT_ENTER that can be handled by the program. Otherwise, i.e. either if this style not specified at all, or it is used, but there is no event handler for this event or the event handler called Event#skip to avoid overriding the default handling, pressing Enter key is either processed internally by the control or used to activate the default button of the dialog, if any.
-
TE_PROCESS_TAB: Normally, TAB key is used for keyboard navigation and pressing it in a control switches focus to the next one. With this style, this won't happen and if the TAB is not otherwise processed (e.g. by EVT_CHAR event handler), a literal TAB character is inserted into the control. Notice that this style has no effect for single-line text controls when using WXGTK.
-
TE_MULTILINE: The text control allows multiple lines. If this style is not specified, line break characters should not be used in the controls value.
-
TE_PASSWORD: The text will be echoed as asterisks.
-
TE_READONLY: The text will not be user-editable.
-
TE_RICH: Use rich text control under MSW, this allows having more than 64KB of text in the control. This style is ignored under other platforms and it is recommended to use TE_RICH2 instead of it under MSW.
-
TE_RICH2: Use rich text control version 2.0 or higher under MSW, this style is ignored under other platforms. Note that this style may be turned on automatically even if it is not used explicitly when creating a text control with a long (i.e. much more than 64KiB) initial text, as creating the control would simply fail in this case under MSW if neither this style nor TE_RICH is used.
-
TE_AUTO_URL: Highlight the URLs and generate the TextUrlEvents when mouse events occur over them.
-
TE_NOHIDESEL: By default, the Windows text control doesn't show the selection when it doesn't have focus - use this style to force it to always show it. It doesn't do anything under other platforms.
-
HSCROLL: A horizontal scrollbar will be created and used, so that text won't be wrapped.
-
TE_NO_VSCROLL: For multiline controls only: vertical scrollbar will never be created. This limits the amount of text which can be entered into the control to what can be displayed in it under WXMSW but not under WXGTK or WXOSX. Currently not implemented for the other platforms.
-
TE_LEFT: The text in the control will be left-justified (default).
-
TE_CENTRE: The text in the control will be centered (WXMSW, WXGTK, WXOSX).
-
TE_RIGHT: The text in the control will be right-justified (WXMSW, WXGTK, WXOSX).
-
TE_DONTWRAP: Same as HSCROLL style: don't wrap at all, show horizontal scrollbar instead.
-
TE_CHARWRAP: For multiline controls only: wrap the lines too long to be shown entirely at any position (Univ, WXGTK, WXOSX).
-
TE_WORDWRAP: For multiline controls only: wrap the lines too long to be shown entirely at word boundaries (Univ, WXMSW, WXGTK, WXOSX).
-
TE_BESTWRAP: For multiline controls only: wrap the lines at word boundaries or at any other character if there are words longer than the window width (this is the default).
-
TE_CAPITALIZE: On PocketPC and Smartphone, causes the first letter to be capitalized.
Note that alignment styles (TE_LEFT, TE_CENTRE and TE_RIGHT) can be changed dynamically after control creation on WXMSW, WXGTK and WXOSX. TE_READONLY, TE_PASSWORD and wrapping styles can be dynamically changed under WXGTK but not WXMSW. The other styles can be only set during control creation.
wxTextCtrl Text Format
The multiline text controls always store the text as a sequence of lines separated by '\n'
characters, i.e. in the Unix text format even on non-Unix platforms. This allows the user code to ignore the differences between the platforms but at a price: the indices in the control such as those returned by Wx::TextEntry#get_insertion_point or Wx::TextEntry#get_selection can not be used as indices into the string returned by Wx::TextEntry#get_value as they’re going to be slightly off for platforms using "\r\n"
as separator (as Windows does). Instead, if you need to obtain a substring between the 2 indices obtained from the control with the help of the functions mentioned above, you should use Wx::TextEntry#get_range. And the indices themselves can only be passed to other methods, for example Wx::TextEntry#set_insertion_point or Wx::TextEntry#set_selection. To summarize: never use the indices returned by (multiline) TextCtrl as indices into the string it contains, but only as arguments to be passed back to the other TextCtrl methods. This problem doesn’t arise for single-line platforms however where the indices in the control do correspond to the positions in the value string.
wxTextCtrl Positions and Coordinates
It is possible to use either linear positions, i.e. roughly (but not always exactly, as explained in the previous section) the index of the character in the text contained in the control or X-Y coordinates, i.e. column and line of the character when working with this class and it provides the functions #position_to_xy and #xy_to_position to convert between the two. Additionally, a position in the control can be converted to its coordinates in pixels using #position_to_coords which can be useful to e.g. show a popup menu near the given character. And, in the other direction, #hit_test can be used to find the character under, or near, the given pixel coordinates. To be more precise, positions actually refer to the gaps between characters and not the characters themselves. Thus, position 0 is the one before the very first character in the control and so is a valid position even when the control is empty. And if the control contains a single character, it has two valid positions: 0 before this character and 1 after it. This, when the documentation of various functions mentions “invalid position”, it doesn’t consider the position just after the last character of the line to be invalid, only the positions beyond that one (e.g. 2 and greater in the single character example) are actually invalid.
wxTextCtrl Styles.
Multi-line text controls support styling, i.e. provide a possibility to set colours and font for individual characters in it (note that under Windows TE_RICH style is required for style support). To use the styles you can either call #set_default_style before inserting the text or call #set_style later to change the style of the text already in the control (the first solution is much more efficient). In either case, if the style doesn’t specify some of the attributes (for example you only want to set the text colour but without changing the font nor the text background), the values of the default style will be used for them. If there is no default style, the attributes of the text control itself are used. So the following code correctly describes what it does: the second call to #set_default_style doesn’t change the text foreground colour (which stays red) while the last one doesn’t change the background colour (which stays grey):
text.set_default_style(Wx::TextAttr.new(Wx::RED))
text.append_text("Red text\n")
text.set_default_style(Wx::TextAttr.new(Wx::NULL_COLOUR, Wx::LIGHT_GREY))
text.append_text("Red on grey text\n")
text.set_default_style(Wx::TextAttr.new(Wx::BLUE))
text.append_text("Blue on grey text\n")
Event Handling.
The following commands are processed by default event handlers in TextCtrl: StandardID::ID_CUT, StandardID::ID_COPY, StandardID::ID_PASTE, StandardID::ID_UNDO, StandardID::ID_REDO. The associated UI update events are also processed automatically, when the control has the focus.
Events emitted by this class
The following event-handler methods redirect the events to member method or handler blocks for CommandEvent events. Event handler methods for events emitted by this class:
-
EvtHandler#evt_text(id, meth = nil, &block): Respond to a EVT_TEXT event, generated when the text changes. Notice that this event will be sent when the text controls contents changes whether this is due to user input or comes from the program itself (for example, if #set_value is called); see #change_value for a function which does not send this event. This event is however not sent during the control creation.
-
EvtHandler#evt_text_enter(id, meth = nil, &block): Respond to a EVT_TEXT_ENTER event, generated when enter is pressed in a text control which must have TE_PROCESS_ENTER style for this event to be generated.
-
EvtHandler#evt_text_url(id, meth = nil, &block): A mouse event occurred over an URL in the text control.
-
EvtHandler#evt_text_maxlen(id, meth = nil, &block): This event is generated when the user tries to enter more text into the control than the limit set by #set_max_length, see its description.
Category: Controls <div class=‘appearance’><span class=‘appearance’>Appearance:</span><table><tr><td> WXMSW Appearance </td><td> WXGTK Appearance </td><td> WXOSX Appearance </td></tr></table></div>
Instance Method Summary collapse
-
#<<(obj) ⇒ self
Appends the string representation of
obj
to the text value of the control. -
#create(parent, id, value = (''), pos = Wx::DEFAULT_POSITION, size = Wx::DEFAULT_SIZE, style = 0, validator = Wx::DEFAULT_VALIDATOR, name = Wx::TEXT_CTRL_NAME_STR) ⇒ Boolean
Creates the text control for two-step construction.
-
#discard_edits ⇒ void
Resets the internal modified flag as if the current changes had been saved.
-
#each_line {|line| ... } ⇒ Object, Enumerator
Yield each line to the given block.
-
#empty_undo_buffer ⇒ void
Delete the undo history.
-
#emulate_key_press(event) ⇒ Boolean
This function inserts into the control the character which would have been inserted if the given key event had occurred in the text control.
- #enable_proof_check(*opts) ⇒ Object
-
#get_default_style ⇒ Wx::TextAttr
(also: #default_style)
Returns the style currently used for the new text.
-
#get_line_length(lineNo) ⇒ Integer
(also: #line_length)
Gets the length of the specified line, not including any trailing newline character(s).
-
#get_line_text(lineNo) ⇒ String
(also: #line_text)
Returns the contents of a given line in the text control, not including any trailing newline character(s).
-
#get_number_of_lines ⇒ Integer
(also: #number_of_lines)
Returns the number of lines in the text control buffer.
-
#get_proof_check_options ⇒ Wx::TextProofOptions
Returns the current text proofing options.
-
#get_style(position, style) ⇒ Boolean
(also: #style)
Returns the style at this position in the text control.
-
#hit_test(pt) ⇒ Array(Wx::TextCtrlHitTestResult,Integer,Integer)
Finds the row and column of the character at the specified point.
-
#initialize(*args) ⇒ TextCtrl
constructor
A new instance of TextCtrl.
-
#is_modified ⇒ Boolean
(also: #modified?)
Returns true if the text has been modified by user.
-
#is_multi_line ⇒ Boolean
(also: #multi_line?)
Returns true if this is a multi line edit control and false otherwise.
-
#is_single_line ⇒ Boolean
(also: #single_line?)
Returns true if this is a single line edit control and false otherwise.
-
#load_file(filename, fileType = Wx::TEXT_TYPE_ANY) ⇒ Boolean
Loads and displays the named file, if it exists.
-
#mark_dirty ⇒ void
Mark text as modified (dirty).
-
#on_drop_files(event) ⇒ void
This event handler function implements default drag and drop behaviour, which is to load the first dropped file into the control.
-
#osx_disable_all_smart_substitutions ⇒ void
Disables all automatic character substitutions.
-
#osx_enable_automatic_dash_substitution(enable) ⇒ void
Enables the automatic conversion of two ASCII hyphens into an m-dash.
-
#osx_enable_automatic_quote_substitution(enable) ⇒ void
Enables the automatic replacement of ASCII quotation marks and apostrophes with their typographic symbols.
-
#osx_enable_new_line_replacement(enable) ⇒ void
Enables the automatic replacement of new lines characters in a single-line text field with spaces under macOS.
-
#position_to_coords(pos) ⇒ Wx::Point
Converts given text position to client coordinates in pixels.
-
#position_to_xy(pos) ⇒ Array(Integer, Integer)?
Converts given position to a zero-based column, line number pair.
-
#save_file(filename = (''), fileType = Wx::TEXT_TYPE_ANY) ⇒ Boolean
Saves the contents of the control in a text file.
-
#set_default_style(style) ⇒ Boolean
(also: #default_style=)
Changes the default style to use for the new text which is going to be added to the control.
-
#set_modified(modified) ⇒ void
(also: #modified=)
Marks the control as being modified by the user or not.
-
#set_style(start, end_, style) ⇒ Boolean
Changes the style of the given range.
-
#show_position(pos) ⇒ void
Makes the line containing the given position visible.
-
#xy_to_position(x, y) ⇒ Integer
Converts the given zero based column and line number to a position.
Methods included from TextEntry
#append_text, #auto_complete, #auto_complete_directories, #auto_complete_file_names, #can_copy, #can_cut, #can_paste, #can_redo, #can_undo, #change_value, #clear, #copy, #cut, #force_upper, #get_hint, #get_insertion_point, #get_last_position, #get_margins, #get_range, #get_selection, #get_string_selection, #get_value, #is_editable, #is_empty, #paste, #redo_, #remove, #replace, #select_all, #select_none, #set_editable, #set_hint, #set_insertion_point, #set_insertion_point_end, #set_margins, #set_max_length, #set_selection, #set_value, #undo, #write_text
Methods inherited from Control
#command, ellipsize, escape_mnemonics, #get_label, #get_label_text, #get_size_from_text, #get_size_from_text_size, remove_mnemonics, #set_label, #set_label_markup, #set_label_text
Methods inherited from Window
#accepts_focus, #accepts_focus_from_keyboard, #accepts_focus_recursively, #add_child, #adjust_for_layout_direction, #always_show_scrollbars, #begin_repositioning_children, #cache_best_size, #can_accept_focus, #can_accept_focus_from_keyboard, #can_scroll, #can_set_transparent, #capture_mouse, #center, #center_on_parent, #centre, #centre_on_parent, #clear_background, #client_to_screen, #client_to_window_size, #close, #convert_dialog_to_pixels, #convert_pixels_to_dialog, #destroy, #destroy_children, #disable, #disable_focus_from_keyboard, #do_update_window_ui, #drag_accept_files, #each_child, #enable, #enable_touch_events, #enable_visible_focus, #end_repositioning_children, find_focus, #find_window_by_id, find_window_by_id, #find_window_by_label, find_window_by_label, #find_window_by_name, find_window_by_name, #fit, #fit_inside, #freeze, #from_dip, from_dip, #from_phys, from_phys, #get_accelerator_table, #get_auto_layout, #get_background_colour, #get_background_style, #get_best_height, #get_best_size, #get_best_virtual_size, #get_best_width, #get_border, get_capture, #get_caret, #get_char_height, #get_char_width, #get_children, get_class_default_attributes, #get_client_area_origin, #get_client_rect, #get_client_size, #get_containing_sizer, #get_content_scale_factor, #get_cursor, #get_default_attributes, #get_dpi, #get_dpi_scale_factor, #get_drop_target, #get_effective_min_size, #get_event_handler, #get_extra_style, #get_font, #get_foreground_colour, #get_grand_parent, #get_help_text, #get_help_text_at_point, #get_id, #get_label, #get_layout_direction, #get_max_client_size, #get_max_height, #get_max_size, #get_max_width, #get_min_client_size, #get_min_height, #get_min_size, #get_min_width, #get_name, #get_next_sibling, #get_parent, #get_popup_menu_selection_from_user, #get_position, #get_prev_sibling, #get_rect, #get_screen_position, #get_screen_rect, #get_scroll_pos, #get_scroll_range, #get_scroll_thumb, #get_size, #get_sizer, #get_text_extent, #get_theme_enabled, #get_tool_tip, #get_tool_tip_text, #get_update_client_rect, #get_update_region, #get_validator, #get_virtual_size, #get_window_border_size, #get_window_style, #get_window_style_flag, #get_window_variant, #handle_as_navigation_key, #handle_window_event, #has_capture, #has_extra_style, #has_flag, #has_focus, #has_multiple_pages, #has_scrollbar, #has_transparent_background, #hide, #hide_with_effect, #inform_first_direction, #inherit_attributes, #inherits_background_colour, #inherits_foreground_colour, #init_dialog, #invalidate_best_size, #is_being_deleted, #is_descendant, #is_double_buffered, #is_enabled, #is_exposed, #is_focusable, #is_frozen, #is_retained, #is_scrollbar_always_shown, #is_shown, #is_shown_on_screen, #is_this_enabled, #is_top_level, #is_transparent_background_supported, #layout, #line_down, #line_up, #locked, #lower_window, #move, #move_after_in_tab_order, #move_before_in_tab_order, #navigate, #navigate_in, new_control_id, #on_internal_idle, #page_down, #page_up, #paint, #paint_buffered, #popup_menu, #post_size_event, #post_size_event_to_parent, #process_window_event, #process_window_event_locally, #push_event_handler, #raise_window, #refresh, #refresh_rect, #register_hot_key, #release_mouse, #remove_child, #remove_event_handler, #reparent, #screen_to_client, #scroll_lines, #scroll_pages, #scroll_window, #send_size_event, #send_size_event_to_parent, #set_accelerator_table, #set_auto_layout, #set_background_colour, #set_background_style, #set_can_focus, #set_caret, #set_client_size, #set_containing_sizer, #set_cursor, #set_double_buffered, #set_drop_target, #set_event_handler, #set_extra_style, #set_focus, #set_focus_from_kbd, #set_font, #set_foreground_colour, #set_help_text, #set_id, #set_initial_size, #set_label, #set_layout_direction, #set_max_client_size, #set_max_size, #set_min_client_size, #set_min_size, #set_name, #set_next_handler, #set_own_background_colour, #set_own_font, #set_own_foreground_colour, #set_position, #set_previous_handler, #set_scroll_pos, #set_scrollbar, #set_size, #set_size_hints, #set_sizer, #set_sizer_and_fit, #set_theme_enabled, #set_tool_tip, #set_transparent, #set_validator, #set_virtual_size, #set_window_style, #set_window_style_flag, #set_window_variant, #should_inherit_colours, #show, #show_with_effect, #switch_sizer, #thaw, #to_dip, to_dip, #to_phys, to_phys, #toggle_window_style, #transfer_data_from_window, #transfer_data_to_window, #unregister_hot_key, unreserve_control_id, #unset_tool_tip, #update, #update_window_ui, #use_background_colour, #use_bg_col, #use_foreground_colour, #validate, #warp_pointer, #window_to_client_size
Methods inherited from EvtHandler
add_filter, #add_pending_event, #call_after, clear_filters, #connect, #delete_pending_events, #disconnect, #evt_activate, #evt_activate_app, #evt_aui_pane_activated, #evt_aui_pane_button, #evt_aui_pane_close, #evt_aui_pane_maximize, #evt_aui_pane_restore, #evt_aui_render, #evt_auinotebook_allow_dnd, #evt_auinotebook_begin_drag, #evt_auinotebook_bg_dclick, #evt_auinotebook_button, #evt_auinotebook_drag_done, #evt_auinotebook_drag_motion, #evt_auinotebook_end_drag, #evt_auinotebook_page_changed, #evt_auinotebook_page_changing, #evt_auinotebook_page_close, #evt_auinotebook_page_closed, #evt_auinotebook_tab_middle_down, #evt_auinotebook_tab_middle_up, #evt_auinotebook_tab_right_down, #evt_auinotebook_tab_right_up, #evt_auitoolbar_begin_drag, #evt_auitoolbar_middle_click, #evt_auitoolbar_overflow_click, #evt_auitoolbar_right_click, #evt_auitoolbar_tool_dropdown, #evt_button, #evt_calculate_layout, #evt_calendar, #evt_calendar_page_changed, #evt_calendar_sel_changed, #evt_calendar_week_clicked, #evt_calendar_weekday_clicked, #evt_char, #evt_char_hook, #evt_checkbox, #evt_checklistbox, #evt_child_focus, #evt_choice, #evt_choicebook_page_changed, #evt_choicebook_page_changing, #evt_close, #evt_collapsiblepane_changed, #evt_colourpicker_changed, #evt_colourpicker_current_changed, #evt_colourpicker_dialog_cancelled, #evt_combobox, #evt_combobox_closeup, #evt_combobox_dropdown, #evt_command, #evt_command_enter, #evt_command_kill_focus, #evt_command_left_click, #evt_command_left_dclick, #evt_command_range, #evt_command_right_click, #evt_command_scroll, #evt_command_scroll_bottom, #evt_command_scroll_changed, #evt_command_scroll_linedown, #evt_command_scroll_lineup, #evt_command_scroll_pagedown, #evt_command_scroll_pageup, #evt_command_scroll_thumbrelease, #evt_command_scroll_thumbtrack, #evt_command_scroll_top, #evt_command_set_focus, #evt_context_menu, #evt_date_changed, #evt_dialup_connected, #evt_dialup_disconnected, #evt_dirctrl_fileactivated, #evt_dirctrl_selectionchanged, #evt_dirpicker_changed, #evt_display_changed, #evt_dpi_changed, #evt_drop_files, #evt_end_session, #evt_enter_window, #evt_erase_background, #evt_filectrl_fileactivated, #evt_filectrl_filterchanged, #evt_filectrl_folderchanged, #evt_filectrl_selectionchanged, #evt_filepicker_changed, #evt_find, #evt_find_close, #evt_find_next, #evt_find_replace, #evt_find_replace_all, #evt_fontpicker_changed, #evt_fullscreen, #evt_gesture_pan, #evt_gesture_rotate, #evt_gesture_zoom, #evt_grid_cell_changed, #evt_grid_cell_changing, #evt_grid_cell_left_click, #evt_grid_cell_left_dclick, #evt_grid_cell_right_click, #evt_grid_cell_right_dclick, #evt_grid_cmd_col_size, #evt_grid_cmd_editor_created, #evt_grid_cmd_range_selected, #evt_grid_cmd_range_selecting, #evt_grid_cmd_row_size, #evt_grid_col_auto_size, #evt_grid_col_move, #evt_grid_col_size, #evt_grid_col_sort, #evt_grid_editor_created, #evt_grid_editor_hidden, #evt_grid_editor_shown, #evt_grid_label_left_click, #evt_grid_label_left_dclick, #evt_grid_label_right_click, #evt_grid_label_right_dclick, #evt_grid_range_selected, #evt_grid_range_selecting, #evt_grid_row_auto_size, #evt_grid_row_move, #evt_grid_row_size, #evt_grid_select_cell, #evt_grid_tabbing, #evt_header_begin_reorder, #evt_header_begin_resize, #evt_header_click, #evt_header_dclick, #evt_header_dragging_cancelled, #evt_header_end_reorder, #evt_header_end_resize, #evt_header_middle_click, #evt_header_middle_dclick, #evt_header_resizing, #evt_header_right_click, #evt_header_right_dclick, #evt_header_separator_dclick, #evt_help, #evt_help_range, #evt_hibernate, #evt_hotkey, #evt_html_cell_clicked, #evt_html_cell_hover, #evt_html_link_clicked, #evt_hyperlink, #evt_iconize, #evt_idle, #evt_init_dialog, #evt_joy_button_down, #evt_joy_button_up, #evt_joy_move, #evt_joy_zmove, #evt_joystick_events, #evt_key_down, #evt_key_up, #evt_kill_focus, #evt_leave_window, #evt_left_dclick, #evt_left_down, #evt_left_up, #evt_list_begin_drag, #evt_list_begin_label_edit, #evt_list_begin_rdrag, #evt_list_cache_hint, #evt_list_col_begin_drag, #evt_list_col_click, #evt_list_col_dragging, #evt_list_col_end_drag, #evt_list_col_right_click, #evt_list_delete_all_items, #evt_list_delete_item, #evt_list_end_label_edit, #evt_list_insert_item, #evt_list_item_activated, #evt_list_item_checked, #evt_list_item_deselected, #evt_list_item_focused, #evt_list_item_middle_click, #evt_list_item_right_click, #evt_list_item_selected, #evt_list_item_unchecked, #evt_list_key_down, #evt_listbook_page_changed, #evt_listbook_page_changing, #evt_listbox, #evt_listbox_dclick, #evt_long_press, #evt_magnify, #evt_maximize, #evt_media_finished, #evt_media_loaded, #evt_media_pause, #evt_media_play, #evt_media_statechanged, #evt_media_stop, #evt_menu, #evt_menu_close, #evt_menu_highlight, #evt_menu_highlight_all, #evt_menu_open, #evt_menu_range, #evt_middle_dclick, #evt_middle_down, #evt_middle_up, #evt_motion, #evt_mouse_aux1_dclick, #evt_mouse_aux1_down, #evt_mouse_aux1_up, #evt_mouse_aux2_dclick, #evt_mouse_aux2_down, #evt_mouse_aux2_up, #evt_mouse_capture_changed, #evt_mouse_capture_lost, #evt_mouse_events, #evt_mousewheel, #evt_move, #evt_move_end, #evt_move_start, #evt_moving, #evt_navigation_key, #evt_notebook_page_changed, #evt_notebook_page_changing, #evt_paint, #evt_pg_changed, #evt_pg_changing, #evt_pg_col_begin_drag, #evt_pg_col_dragging, #evt_pg_col_end_drag, #evt_pg_double_click, #evt_pg_highlighted, #evt_pg_item_collapsed, #evt_pg_item_expanded, #evt_pg_label_edit_begin, #evt_pg_label_edit_ending, #evt_pg_page_changed, #evt_pg_right_click, #evt_pg_selected, #evt_press_and_tap, #evt_query_end_session, #evt_query_layout_info, #evt_radiobox, #evt_radiobutton, #evt_ribbonbar_help_click, #evt_ribbonbar_page_changed, #evt_ribbonbar_page_changing, #evt_ribbonbar_tab_left_dclick, #evt_ribbonbar_tab_middle_down, #evt_ribbonbar_tab_middle_up, #evt_ribbonbar_tab_right_down, #evt_ribbonbar_tab_right_up, #evt_ribbonbar_toggled, #evt_ribbonbuttonbar_clicked, #evt_ribbonbuttonbar_dropdown_clicked, #evt_ribbongallery_clicked, #evt_ribbongallery_hover_changed, #evt_ribbongallery_selected, #evt_ribbonpanel_extbutton_activated, #evt_ribbontoolbar_clicked, #evt_ribbontoolbar_dropdown_clicked, #evt_richtext_buffer_reset, #evt_richtext_character, #evt_richtext_consuming_character, #evt_richtext_content_deleted, #evt_richtext_content_inserted, #evt_richtext_delete, #evt_richtext_focus_object_changed, #evt_richtext_left_click, #evt_richtext_left_dclick, #evt_richtext_middle_click, #evt_richtext_properties_changed, #evt_richtext_return, #evt_richtext_right_click, #evt_richtext_selection_changed, #evt_richtext_style_changed, #evt_richtext_stylesheet_changed, #evt_richtext_stylesheet_replaced, #evt_richtext_stylesheet_replacing, #evt_right_dclick, #evt_right_down, #evt_right_up, #evt_sash_dragged, #evt_sash_dragged_range, #evt_scroll, #evt_scroll_bottom, #evt_scroll_changed, #evt_scroll_command, #evt_scroll_linedown, #evt_scroll_lineup, #evt_scroll_pagedown, #evt_scroll_pageup, #evt_scroll_thumbrelease, #evt_scroll_thumbtrack, #evt_scroll_top, #evt_scrollbar, #evt_scrollwin, #evt_scrollwin_bottom, #evt_scrollwin_linedown, #evt_scrollwin_lineup, #evt_scrollwin_pagedown, #evt_scrollwin_pageup, #evt_scrollwin_thumbrelease, #evt_scrollwin_thumbtrack, #evt_scrollwin_top, #evt_search, #evt_search_cancel, #evt_set_cursor, #evt_set_focus, #evt_show, #evt_size, #evt_slider, #evt_spin, #evt_spin_down, #evt_spin_up, #evt_spinctrl, #evt_spinctrldouble, #evt_splitter_dclick, #evt_splitter_sash_pos_changed, #evt_splitter_sash_pos_changing, #evt_splitter_sash_pos_resize, #evt_splitter_unsplit, #evt_stc_autocomp_cancelled, #evt_stc_autocomp_char_deleted, #evt_stc_autocomp_completed, #evt_stc_autocomp_selection, #evt_stc_autocomp_selection_change, #evt_stc_calltip_click, #evt_stc_change, #evt_stc_charadded, #evt_stc_clipboard_copy, #evt_stc_clipboard_paste, #evt_stc_do_drop, #evt_stc_doubleclick, #evt_stc_drag_over, #evt_stc_dwellend, #evt_stc_dwellstart, #evt_stc_hotspot_click, #evt_stc_hotspot_dclick, #evt_stc_hotspot_release_click, #evt_stc_indicator_click, #evt_stc_indicator_release, #evt_stc_macrorecord, #evt_stc_margin_right_click, #evt_stc_marginclick, #evt_stc_modified, #evt_stc_needshown, #evt_stc_painted, #evt_stc_romodifyattempt, #evt_stc_savepointleft, #evt_stc_savepointreached, #evt_stc_start_drag, #evt_stc_styleneeded, #evt_stc_updateui, #evt_stc_userlistselection, #evt_stc_zoom, #evt_sys_colour_changed, #evt_taskbar_click, #evt_taskbar_left_dclick, #evt_taskbar_left_down, #evt_taskbar_left_up, #evt_taskbar_move, #evt_taskbar_right_dclick, #evt_taskbar_right_down, #evt_taskbar_right_up, #evt_text, #evt_text_copy, #evt_text_cut, #evt_text_enter, #evt_text_maxlen, #evt_text_paste, #evt_text_url, #evt_time_changed, #evt_timer, #evt_togglebutton, #evt_tool, #evt_tool_dropdown, #evt_tool_enter, #evt_tool_range, #evt_tool_rclicked, #evt_tool_rclicked_range, #evt_toolbook_page_changed, #evt_toolbook_page_changing, #evt_tree_begin_drag, #evt_tree_begin_label_edit, #evt_tree_begin_rdrag, #evt_tree_delete_item, #evt_tree_end_drag, #evt_tree_end_label_edit, #evt_tree_get_info, #evt_tree_item_activated, #evt_tree_item_collapsed, #evt_tree_item_collapsing, #evt_tree_item_expanded, #evt_tree_item_expanding, #evt_tree_item_gettooltip, #evt_tree_item_menu, #evt_tree_item_middle_click, #evt_tree_item_right_click, #evt_tree_key_down, #evt_tree_sel_changed, #evt_tree_sel_changing, #evt_tree_set_info, #evt_tree_state_image_click, #evt_treebook_node_collapsed, #evt_treebook_node_expanded, #evt_treebook_page_changed, #evt_treebook_page_changing, #evt_two_finger_tap, #evt_update_ui, #evt_update_ui_range, #evt_window_create, #evt_window_destroy, #evt_wizard_before_page_changed, #evt_wizard_cancel, #evt_wizard_finished, #evt_wizard_help, #evt_wizard_page_changed, #evt_wizard_page_changing, #evt_wizard_page_shown, #get_client_object, #get_evt_handler_enabled, #get_next_handler, #get_previous_handler, #is_unlinked, #process_event, #process_event_locally, #process_pending_events, #queue_event, register_class, remove_filter, #safely_process_event, #set_client_object, #set_evt_handler_enabled, #set_next_handler, #set_previous_handler, #try_after, #try_before, #unlink
Methods inherited from Object
#clone, #dup, #is_same_as, #un_share
Constructor Details
#initialize ⇒ Wx::TextCtrl #initialize(parent, id, value = (''), pos = Wx::DEFAULT_POSITION, size = Wx::DEFAULT_SIZE, style = 0, validator = Wx::DEFAULT_VALIDATOR, name = Wx::TEXT_CTRL_NAME_STR) ⇒ Wx::TextCtrl
Returns a new instance of TextCtrl.
646 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 646 def initialize(*args) end |
Instance Method Details
#<<(obj) ⇒ self
Appends the string representation of obj
to the text value of the control. Calls #to_s to get the string representation of obj
.
67 |
# File 'lib/wx/doc/textctrl.rb', line 67 def <<(obj) end |
#create(parent, id, value = (''), pos = Wx::DEFAULT_POSITION, size = Wx::DEFAULT_SIZE, style = 0, validator = Wx::DEFAULT_VALIDATOR, name = Wx::TEXT_CTRL_NAME_STR) ⇒ Boolean
Creates the text control for two-step construction.
This method should be called if the default constructor was used for the control creation. Its parameters have the same meaning as for the non-default constructor.
660 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 660 def create(parent, id, value=(''), pos=Wx::DEFAULT_POSITION, size=Wx::DEFAULT_SIZE, style=0, validator=Wx::DEFAULT_VALIDATOR, name=Wx::TEXT_CTRL_NAME_STR) end |
#discard_edits ⇒ void
This method returns an undefined value.
Resets the internal modified flag as if the current changes had been saved.
664 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 664 def discard_edits; end |
#each_line {|line| ... } ⇒ Object, Enumerator
Yield each line to the given block. Returns an Enumerator if no block given.
73 |
# File 'lib/wx/doc/textctrl.rb', line 73 def each_line; end |
#empty_undo_buffer ⇒ void
This method returns an undefined value.
Delete the undo history.
Currently only implemented in WXMSW (for controls using Wx::TE_RICH2 style only) and WXOSX (for multiline text controls only), does nothing in the other ports or for the controls not using the appropriate styles.
670 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 670 def empty_undo_buffer; end |
#emulate_key_press(event) ⇒ Boolean
This function inserts into the control the character which would have been inserted if the given key event had occurred in the text control.
The event object should be the same as the one passed to EVT_KEY_DOWN handler previously by wxWidgets. Please note that this function doesn’t currently work correctly for all keys under any platform but MSW. true if the event resulted in a change to the control, false otherwise.
678 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 678 def emulate_key_press(event) end |
#enable_proof_check(text_proof_options = Wx::TextProofOptions.default) ⇒ Boolean #enable_proof_check(spell_checking, grammar_checking, language) ⇒ Boolean
95 |
# File 'lib/wx/doc/textctrl.rb', line 95 def enable_proof_check(*opts) end |
#get_default_style ⇒ Wx::TextAttr Also known as: default_style
Returns the style currently used for the new text.
685 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 685 def get_default_style; end |
#get_line_length(lineNo) ⇒ Integer Also known as: line_length
Gets the length of the specified line, not including any trailing newline character(s).
The length of the line, or -1 if lineNo was invalid.
693 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 693 def get_line_length(lineNo) end |
#get_line_text(lineNo) ⇒ String Also known as: line_text
Returns the contents of a given line in the text control, not including any trailing newline character(s).
The contents of the line.
701 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 701 def get_line_text(lineNo) end |
#get_number_of_lines ⇒ Integer Also known as: number_of_lines
Returns the number of lines in the text control buffer.
The returned number is the number of logical lines, i.e. just the count of the number of newline characters in the control + 1, for WXGTK and WXOSX/Cocoa ports while it is the number of physical lines, i.e. the count of lines actually shown in the control, in WXMSW. Because of this discrepancy, it is not recommended to use this function.
Note that even empty text controls have one line (where the insertion point is), so #get_number_of_lines never returns 0.
714 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 714 def get_number_of_lines; end |
#get_proof_check_options ⇒ Wx::TextProofOptions
Returns the current text proofing options. Only available if Wx.has_feature?(:USE_SPELLCHECK)
returns true.
101 |
# File 'lib/wx/doc/textctrl.rb', line 101 def ; end |
#get_style(position, style) ⇒ Boolean Also known as: style
Returns the style at this position in the text control.
Not all platforms support this function. true on success, false if an error occurred (this may also mean that the styles are not supported under this platform).
726 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 726 def get_style(position, style) end |
#hit_test(pt) ⇒ Array(Wx::TextCtrlHitTestResult,Integer,Integer)
Finds the row and column of the character at the specified point.
If the return code is not Wx::TextCtrlHitTestResult::TE_HT_UNKNOWN the row and column of the character closest to this position are returned, otherwise the output parameters are not modified. Please note that this function is currently only implemented in Univ, WXMSW and WXGTK ports and always returns Wx::TextCtrlHitTestResult::TE_HT_UNKNOWN in the other ports.
737 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 737 def hit_test(pt) end |
#is_modified ⇒ Boolean Also known as: modified?
Returns true if the text has been modified by user.
Note that calling Wx::TextEntry#set_value doesn’t make the control modified.
744 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 744 def is_modified; end |
#is_multi_line ⇒ Boolean Also known as: multi_line?
Returns true if this is a multi line edit control and false otherwise.
752 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 752 def is_multi_line; end |
#is_single_line ⇒ Boolean Also known as: single_line?
Returns true if this is a single line edit control and false otherwise.
761 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 761 def is_single_line; end |
#load_file(filename, fileType = Wx::TEXT_TYPE_ANY) ⇒ Boolean
Loads and displays the named file, if it exists.
true if successful, false otherwise.
770 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 770 def load_file(filename, fileType=Wx::TEXT_TYPE_ANY) end |
#mark_dirty ⇒ void
This method returns an undefined value.
Mark text as modified (dirty).
777 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 777 def mark_dirty; end |
#on_drop_files(event) ⇒ void
This method returns an undefined value.
This event handler function implements default drag and drop behaviour, which is to load the first dropped file into the control.
This is not implemented on non-Windows platforms.
789 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 789 def on_drop_files(event) end |
#osx_disable_all_smart_substitutions ⇒ void
This method returns an undefined value.
Disables all automatic character substitutions.
Availability: only available for the WXOSX/Cocoa port.
622 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 622 def osx_disable_all_smart_substitutions; end |
#osx_enable_automatic_dash_substitution(enable) ⇒ void
This method returns an undefined value.
Enables the automatic conversion of two ASCII hyphens into an m-dash.
This feature is enabled by default. Availability: only available for the WXOSX/Cocoa port.
613 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 613 def osx_enable_automatic_dash_substitution(enable) end |
#osx_enable_automatic_quote_substitution(enable) ⇒ void
This method returns an undefined value.
Enables the automatic replacement of ASCII quotation marks and apostrophes with their typographic symbols.
This feature is enabled by default. Availability: only available for the WXOSX/Cocoa port.
604 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 604 def osx_enable_automatic_quote_substitution(enable) end |
#osx_enable_new_line_replacement(enable) ⇒ void
This method returns an undefined value.
Enables the automatic replacement of new lines characters in a single-line text field with spaces under macOS.
This feature is enabled by default and will replace any new line (\n
) character entered into a single-line text field with the space character. Usually single-line text fields are not expected to hold multiple lines of text (that is what Wx::TE_MULTILINE is for, after all) and it is impossible to have multiple lines of text in them under non-Mac platforms. However, under macOS/Cocoa, a single-line text control can still show multiple lines and this function allows to lift the restriction preventing multiple lines from being entered unless Wx::TE_MULTILINE is specified.
Has no effect if the Wx::TE_MULTILINE flag is set on a text control.
Availability: only available for the WXOSX/Cocoa port.
595 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 595 def osx_enable_new_line_replacement(enable) end |
#position_to_coords(pos) ⇒ Wx::Point
Converts given text position to client coordinates in pixels.
This function allows finding where is the character at the given position displayed in the text control. Availability: only available for the WXMSW, WXGTK ports. . Additionally, WXGTK only implements this method for multiline controls and DEFAULT_POSITION is always returned for the single line ones.
On success returns a Point which contains client coordinates for the given position in pixels, otherwise returns DEFAULT_POSITION.
810 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 810 def position_to_coords(pos) end |
#position_to_xy(pos) ⇒ Array(Integer, Integer)?
Converts given position to a zero-based column, line number pair.
true on success, false on failure (most likely due to a too large position parameter).
797 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 797 def position_to_xy(pos) end |
#save_file(filename = (''), fileType = Wx::TEXT_TYPE_ANY) ⇒ Boolean
Saves the contents of the control in a text file.
true if the operation was successful, false otherwise.
818 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 818 def save_file(filename=(''), fileType=Wx::TEXT_TYPE_ANY) end |
#set_default_style(style) ⇒ Boolean Also known as: default_style=
Changes the default style to use for the new text which is going to be added to the control.
This applies both to the text added programmatically using Wx::TextEntry#write_text or Wx::TextEntry#append_text and to the text entered by the user interactively. If either of the font, foreground, or background colour is not set in style, the values of the previous default style are used for them. If the previous default style didn’t set them either, the global font or colours of the text control itself are used as fall back. However if the style parameter is the default Wx::TextAttr, then the default style is just reset (instead of being combined with the new style which wouldn’t change it at all).
true on success, false if an error occurred (this may also mean that the styles are not supported under this platform).
830 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 830 def set_default_style(style) end |
#set_modified(modified) ⇒ void Also known as: modified=
This method returns an undefined value.
Marks the control as being modified by the user or not.
840 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 840 def set_modified(modified) end |
#set_style(start, end_, style) ⇒ Boolean
Changes the style of the given range.
If any attribute within style is not set, the corresponding attribute from #get_default_style is used.
true on success, false if an error occurred (this may also mean that the styles are not supported under this platform).
854 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 854 def set_style(start, end_, style) end |
#show_position(pos) ⇒ void
This method returns an undefined value.
Makes the line containing the given position visible.
859 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 859 def show_position(pos) end |
#xy_to_position(x, y) ⇒ Integer
Converts the given zero based column and line number to a position.
The position value, or -1 if x or y was invalid.
867 |
# File 'lib/wx/doc/gen/text_ctrl.rb', line 867 def xy_to_position(x, y) end |