Class: TkWrapper::Widgets::AutoResizeText

Inherits:
Text show all
Defined in:
lib/widgets/auto_resize_text.rb

Instance Attribute Summary

Attributes inherited from Base::Widget

#cell, #childs, #config, #ids, #manager, #parent, #winfo

Instance Method Summary collapse

Methods inherited from Text

#tk_class

Methods inherited from Base::Widget

#create_tk_widget, #each, #init_id, #initialize, #normalize_childs, #push, #tk_class, #tk_widget

Constructor Details

This class inherits a constructor from TkWrapper::Widgets::Base::Widget

Instance Method Details

#build(parent, **args) ⇒ Object



6
7
8
9
10
# File 'lib/widgets/auto_resize_text.rb', line 6

def build(parent, **args)
  super(parent, **args)
  bind('<Modified>', ->(ev) { resize(ev) })
  bind('<Modified>', -> { puts 'hihi' })
end

#resize(event) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/widgets/auto_resize_text.rb', line 12

def resize(event)
  return unless tk_widget.modified?

  puts event
  puts 'yes!'
  tk_widget.modified(false)
  #max_width = [@cell.bbox[2], 0].max
  #puts @font.metrics
  #new_width = [[@min_width, text_width + @add_width].max, max_width].min
  #tk_widget.width = 0
  #tk_widget.grid(ipadx: new_width / 2.0)
  #@parent.tk_widget.update
end