Class: Redcar::ModelessListDialog
- Inherits:
-
Object
- Object
- Redcar::ModelessListDialog
- Includes:
- Model, Observable
- Defined in:
- plugins/application/lib/application/dialogs/modeless_list_dialog.rb
Overview
A type of dialog for displaying a list inside a tab. Example uses include selection dialogs for code completion or dynamically opening files based on tab content. Modeless List dialogs can also add sub-lists, by implementing the 'previous_list' and/or 'next_list' methods, which are called when a ARROW_LEFT or ARROW_RIGHT key event is generated.
Subclasses should implement the 'selected' method, and optionally 'previous_list' and 'next_list' if applicable.
Direct Known Subclasses
Constant Summary
Constant Summary
Constants included from Observable
Instance Attribute Summary
Attributes included from Model
Instance Method Summary (collapse)
- - (Object) close
-
- (Object) close_on_lost_focus
Whether to close the list dialog when focus is lost.
-
- (ModelessListDialog) initialize(close_on_lost_focus = true)
constructor
A new instance of ModelessListDialog.
-
- (Array<String>) next_list
Get a 'next' list, where applicable, based on the currently selected item in the list.
- - (Object) open
-
- (Array<String>) previous_list
Get a 'previous' list, where applicable, based on the currently selected item in the list.
-
- (String) select(index)
Get the text of an item at an index.
-
- (Object) selected(index)
Do an action, based on the index of the selected item.
-
- (Integer) selection_index
The index of the currently selected text.
-
- (Object) set_location(offset)
Set the location of the list dialog relative to an offset in a tab.
-
- (Object) set_size(width, height)
Set the size of the list dialog.
-
- (Object) update_list(items)
Update the items in the dialog list.
Methods included from Observable
#add_listener, #notify_listeners, #remove_listener
Methods included from ReentryHelpers
Constructor Details
- (ModelessListDialog) initialize(close_on_lost_focus = true)
A new instance of ModelessListDialog
16 17 18 19 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 16 def initialize(close_on_lost_focus=true) @close_on_lost_focus = close_on_lost_focus self.controller = Redcar.gui.controller_for(self).new(self) end |
Instance Method Details
- (Object) close
35 36 37 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 35 def close notify_listeners(:close) end |
- (Object) close_on_lost_focus
Whether to close the list dialog when focus is lost
40 41 42 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 40 def close_on_lost_focus @close_on_lost_focus end |
- (Array<String>) next_list
Get a 'next' list, where applicable, based on the currently selected item in the list
55 56 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 55 def next_list end |
- (Object) open
31 32 33 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 31 def open notify_listeners(:open) end |
- (Array<String>) previous_list
Get a 'previous' list, where applicable, based on the currently selected item in the list
48 49 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 48 def previous_list end |
- (String) select(index)
Get the text of an item at an index
74 75 76 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 74 def select(index) self.controller.select index end |
- (Object) selected(index)
Do an action, based on the index of the selected item
66 67 68 69 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 66 def selected(index) p "'#{select(index)}' (at index #{index}) was selected!" close end |
- (Integer) selection_index
The index of the currently selected text
81 82 83 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 81 def selection_index self.controller.selection_index end |
- (Object) set_location(offset)
Set the location of the list dialog relative to an offset in a tab
27 28 29 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 27 def set_location(offset) notify_listeners(:set_location,offset) end |
- (Object) set_size(width, height)
Set the size of the list dialog. The width is measured in pixels and the height in rows of text
23 24 25 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 23 def set_size(width,height) notify_listeners(:set_size, width,height) end |
- (Object) update_list(items)
Update the items in the dialog list
61 62 63 |
# File 'plugins/application/lib/application/dialogs/modeless_list_dialog.rb', line 61 def update_list(items) notify_listeners :update_list, items end |