Sha256: ec4b681cde5378b535c10012dab8bc3cea61200ff90acc5f582315d8bdb1668d
Contents?: true
Size: 1.76 KB
Versions: 3
Compression:
Stored size: 1.76 KB
Contents
module Gosu class TextInput def initialize __text_input = GosuFFI.Gosu_TextInput_create() GosuFFI.check_last_error @memory_pointer = FFI::AutoPointer.new(__text_input, GosuFFI.method(:Gosu_TextInput_destroy)) @__filter_proc = proc { |data, text| protected_filter(text) } GosuFFI.Gosu_TextInput_set_filter(__pointer, @__filter_proc, nil) GosuFFI.check_last_error end def __pointer @memory_pointer end def text GosuFFI.check_last_error(GosuFFI.Gosu_TextInput_text(__pointer)) end def text=(string) GosuFFI.Gosu_TextInput_set_text(__pointer, string.to_s) GosuFFI.check_last_error end def caret_pos GosuFFI.check_last_error(GosuFFI.Gosu_TextInput_caret_pos(__pointer)) end def caret_pos=(int) GosuFFI.Gosu_TextInput_set_caret_pos(__pointer, int) GosuFFI.check_last_error end def selection_start GosuFFI.check_last_error(GosuFFI.Gosu_TextInput_selection_start(__pointer)) end def selection_start=(int) GosuFFI.Gosu_TextInput_set_selection_start(__pointer, int) GosuFFI.check_last_error end def filter(text) return text end def insert_text(text) GosuFFI.Gosu_TextInput_insert_text(__pointer, text) GosuFFI.check_last_error end def delete_backward GosuFFI.Gosu_TextInput_delete_backward(__pointer) GosuFFI.check_last_error end def delete_forward GosuFFI.Gosu_TextInput_delete_forward(__pointer) GosuFFI.check_last_error end # Ensures that filter_result is set on C side before filter callback returns private def protected_filter(text) string = filter(text) GosuFFI.Gosu_TextInput_set_filter_result(__pointer, string) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gosu-2.0.0.pre8 | lib/gosu/text_input.rb |
gosu-2.0.0.pre7 | lib/gosu/text_input.rb |
gosu-2.0.0.pre6 | lib/gosu/text_input.rb |