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.
Note: Green Shoes doesn't support contents
method.
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 'Left'; -1
when '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
end
end
Return a text marker start position.
Highlight a part of text from marker start position to cursor position.
Shoes.app do
background gainsboro
extend HH::Markup
code = 'alert "Hello Green 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
Return some marked-up text for Pango.
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: Green Shoes doesn't support to_s
method.
Next: Timers