Class: Wads::Dialog
Instance Attribute Summary collapse
Attributes inherited from Widget
#base_z, #children, #gui_theme, #height, #is_selected, #layout, #overlay_widget, #override_color, #text_input_fields, #visible, #width, #x, #y
Instance Method Summary
collapse
Methods inherited from Widget
#add, #add_axis_lines, #add_button, #add_child, #add_delete_button, #add_document, #add_graph_display, #add_image, #add_multi_select_table, #add_overlay, #add_panel, #add_plot, #add_single_select_table, #add_table, #add_text, #border_color, #bottom_edge, #button_down, #button_up, #center_children, #center_x, #center_y, #clear_children, #contains_click, #debug, #disable_background, #disable_border, #draw, #draw_background, #draw_border, #enable_background, #enable_border, #error, #get_layout, #get_theme, #graphics_color, #handle_mouse_up, #handle_right_mouse, #handle_update, #info, #intercept_widget_event, #left_edge, #move_recursive_absolute, #move_recursive_delta, #overlaps_with, #relative_x, #relative_y, #relative_z_order, #remove_child, #remove_children, #remove_children_by_type, #right_edge, #selection_color, #set_absolute_position, #set_dimensions, #set_layout, #set_selected, #set_theme, #text_color, #top_edge, #unset_selected, #update, #uses_layout, #warn, #widget_z, #x_pixel_to_screen, #y_pixel_to_screen, #z_order
Constructor Details
#initialize(x, y, width, height, title, text_input_default) ⇒ Dialog
Returns a new instance of Dialog.
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
|
# File 'lib/wads/widgets.rb', line 2033
def initialize(x, y, width, height, title, text_input_default)
super(x, y, width, height)
@base_z = 10
@error_message = nil
add_text(title, 5, 5)
add_document(content, 0, 56, width, height)
@textinput = TextField.new(x + 10, bottom_edge - 80, text_input_default, 600)
@textinput.base_z = 10
add_child(@textinput)
ok_button = add_button("OK", (@width / 2) - 100, height - 32) do
handle_ok
end
ok_button.width = 100
cancel_button = add_button("Cancel", (@width / 2) + 50, height - 32) do
WidgetResult.new(true)
end
cancel_button.width = 100
end
|
Instance Attribute Details
#textinput ⇒ Object
Returns the value of attribute textinput.
2031
2032
2033
|
# File 'lib/wads/widgets.rb', line 2031
def textinput
@textinput
end
|
Instance Method Details
#add_error_message(msg) ⇒ Object
2066
2067
2068
2069
|
# File 'lib/wads/widgets.rb', line 2066
def add_error_message(msg)
@error_message = ErrorMessage.new(x + 10, bottom_edge - 120, msg)
@error_message.base_z = @base_z
end
|
#content ⇒ Object
2059
2060
2061
2062
2063
2064
|
# File 'lib/wads/widgets.rb', line 2059
def content
<<~HEREDOC
Override the content method to
put your info here.
HEREDOC
end
|
#handle_key_press(id, mouse_x, mouse_y) ⇒ Object
2097
2098
2099
2100
2101
|
# File 'lib/wads/widgets.rb', line 2097
def handle_key_press id, mouse_x, mouse_y
if id == Gosu::KbEscape
return WidgetResult.new(true)
end
end
|
#handle_mouse_click(mouse_x, mouse_y) ⇒ Object
2083
2084
2085
2086
|
# File 'lib/wads/widgets.rb', line 2083
def handle_mouse_click(mouse_x, mouse_y)
end
|
#handle_mouse_down(mouse_x, mouse_y) ⇒ Object
2088
2089
2090
2091
2092
2093
2094
2095
|
# File 'lib/wads/widgets.rb', line 2088
def handle_mouse_down mouse_x, mouse_y
WadsConfig.instance.get_window.text_input = [@textinput].find { |tf| tf.under_point?(mouse_x, mouse_y) }
WadsConfig.instance.get_window.text_input.move_caret(mouse_x) unless WadsConfig.instance.get_window.text_input.nil?
handle_mouse_click(mouse_x, mouse_y)
end
|
#handle_ok ⇒ Object
2077
2078
2079
2080
2081
|
# File 'lib/wads/widgets.rb', line 2077
def handle_ok
return WidgetResult.new(true, EVENT_OK)
end
|
#render ⇒ Object
2071
2072
2073
2074
2075
|
# File 'lib/wads/widgets.rb', line 2071
def render
if @error_message
@error_message.draw
end
end
|