Class: Canis::TextActionEvent
- Inherits:
-
ActionEvent
- Object
- Struct
- ActionEvent
- Canis::TextActionEvent
- Defined in:
- lib/canis/core/include/ractionevent.rb
Overview
a derivative of Action Event for textviews We allow a user to press ENTER on a row and use that for processing. We are basically using TextView as a list in which user can scroll around and move cursor at will.
Instance Attribute Summary collapse
-
#curpos ⇒ Object
cursor position on the line.
-
#current_index ⇒ Object
current_index or line number starting 0.
Attributes inherited from ActionEvent
#action_command, #event, #source
Instance Method Summary collapse
-
#initialize(source, event, action_command, current_index, curpos) ⇒ TextActionEvent
constructor
A new instance of TextActionEvent.
-
#text ⇒ Object
the text of the line on which the user is.
-
#word_under_cursor(line = text(), pos = @curpos, delim = " ") ⇒ Object
the word under the cursor TODO if its a text with pipe delim, then ??.
Methods inherited from ActionEvent
Constructor Details
#initialize(source, event, action_command, current_index, curpos) ⇒ TextActionEvent
Returns a new instance of TextActionEvent.
46 47 48 49 50 |
# File 'lib/canis/core/include/ractionevent.rb', line 46 def initialize source, event, action_command, current_index, curpos super source, event, action_command @current_index = current_index @curpos = curpos end |
Instance Attribute Details
#curpos ⇒ Object
cursor position on the line
45 46 47 |
# File 'lib/canis/core/include/ractionevent.rb', line 45 def curpos @curpos end |
#current_index ⇒ Object
current_index or line number starting 0
43 44 45 |
# File 'lib/canis/core/include/ractionevent.rb', line 43 def current_index @current_index end |
Instance Method Details
#text ⇒ Object
the text of the line on which the user is
52 53 54 |
# File 'lib/canis/core/include/ractionevent.rb', line 52 def text source.current_value.to_s end |
#word_under_cursor(line = text(), pos = @curpos, delim = " ") ⇒ Object
the word under the cursor TODO if its a text with pipe delim, then ??
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/canis/core/include/ractionevent.rb', line 57 def word_under_cursor line=text(), pos=@curpos, delim=" " line ||= text() pos ||= @curpos # if pressed on a space, try to go to next word to make easier 2013-03-24 if line[pos,1] == delim while line[pos,1] == delim pos += 1 end end finish = line.index(delim, pos) start = line.rindex(delim,pos) finish = -1 if finish.nil? start = 0 if start.nil? return line[start..finish] end |