All of the various types of TextBlock are found on the Element Creation page.
Lists all of the strings and styled text objects inside this block.
Return a text cursor position. That is an index of the text which is a string of all of the characters in this text box.
Shows or hides the text cursor. Using cursor = 3
, for instance, shows the text cursor at index 3 from the front. Using cursor = -1
shows the text cursor at the end of the text. Using cursor = nil
hides the text cursor.
Shoes.app do
msg = para 'hello ' * 20
msg.cursor = -1
keypress do |k|
n = case k
when 'ARROW_LEFT'; -1
when 'ARROW_RIGHT'; 1
else
next
end
n += msg.cursor
len = msg.text.length
n = len unless n > -1
msg.cursor = n % (len+1)
flush
end
end
Return an array which includes a text marker start position and highlighted length.
Return an index of the text at which the mouse cursor points on. The left
and top
are the mouse coordinates.
Shoes.app do
para 'index: ', width: 50
index = para '', width: 20
msg = title 'hello ' * 5
click do |b, x, y|
index.text = msg.hit(x, y).to_s
end
end
Return a text marker start position.
Note: Purple Shoes doesn't support marker
method.
Highlight a part of text from marker start position to cursor position.
# Not yet available
Shoes.app do
background gainsboro
extend HH::Markup
code = 'alert "Hello Purple Shoes! " * 5'
msg = para highlight code, nil
button 'marker' do
msg.cursor = 17
msg.marker = 14
msg.text = highlight msg.markup, nil
para msg.highlight
flush
end
end
Note: Purple Shoes doesn't support marker=
method.
Return a string as same as text().
Replaces the text of the entire block with the characters of a string
.
Return a string of all of the characters in this text box. This will strip off any style or text classes and just return the actual characters, as if seen on the screen.
Replaces the text of the entire block with the characters of a string
.
An alias for text. Returns a flattened string of all of this TextBlock's contents.
Note: Purple Shoes doesn't support to_s
method.
Next: Timers