Sha256: 4d693d49c7008dc23ed09132929b9e8d556d84e53d03db5d89c930b26550f3ec

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

# input text example

def input_text(default_text)
  t = text({ content: default_text, x: 333, y: 33, atome_id: :my_text_input })
  t.visual(33)
  t.key(:down) do |evt|
    `if($("#"+#{t.atome_id}).text().length === 15 && event.keyCode != 8) {
  	event.preventDefault();
 }`
    w_get = JSUtils.client_width(t.atome_id)
    t.width = :auto
    t.width = if w_get > 300
                300
              else
                :auto
              end
  end

  t.key(:up) do |evt|
    # todo: get and limit number of char
    # we use .read to get the content according to the current language
    # content_found=t.content.read
    # content_length=content_found.values[0].length
    # # t.content.read.length
    # if content_length > 10
    #   t.content = content_found
    # else
    #
    # end
    w_get = JSUtils.client_width(t.atome_id)
    t.width = if w_get < 99
                99
              elsif w_get > 300
                300
              else
                :auto
              end
    JSUtils.client_height(t.atome_id)
    # infos.content = w_get
  end

  t.border(({ color: :red, thickness: 3, pattern: :dashed }))

  t.over do
    t.visual({ select: :all })
  end

  t.touch do
    t.visual({ select: :all })
  end
  return t
end

input_text("type here,15 char max!!")

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
atome-0.4.7.0 vendor/assets/build/medias/rubies/examples/Old_examples/input_text.rb
atome-0.4.5.4 vendor/assets/build/medias/rubies/examples/Old_examples/input_text.rb