class Fidgit::MenuPane::Item

An item within the menu.

Attributes

shortcut_text[R]
value[R]

Public Class Methods

new(text, value, options = {}) click to toggle source

@param (see Button#initialize)

@option (see Button#initialize) @param [any] value Value if the user picks this item @option options [String] :shortcut_text ('')

Calls superclass method Fidgit::Button::new
# File lib/fidgit/elements/menu_pane.rb, line 14
def initialize(text, value, options = {})
  options = {
    enabled: true,
    border_color: default(:border_color),
    shortcut_text: '',
  }.merge! options

  @value = value
  @shortcut_text = options[:shortcut_text]

  super(text, options)
end

Public Instance Methods

draw_foreground() click to toggle source
Calls superclass method
# File lib/fidgit/elements/menu_pane.rb, line 27
def draw_foreground
  super

  unless @shortcut_text.empty?
    font.draw_rel("#{@shortcut_text}", rect.right - padding_right, y + ((height - font.height) / 2).floor, z, 1, 0, 1, 1, color)
  end

  nil
end

Protected Instance Methods

layout() click to toggle source
Calls superclass method
# File lib/fidgit/elements/menu_pane.rb, line 38
def layout
  super

  # Ignore layout request when asked before TextLine has been created.
  rect.width += font.text_width("  #{@shortcut_text}") unless @shortcut_text.empty? or @text.nil?

  nil
end