thomthom / SKUI

Ruby wrapper of classes that maps to GUI controls in SketchUp's UI::WebDialogs
MIT License
26 stars 14 forks source link

.visible? not initialised and" window not visible" error (two "friend" bugs?) #104

Open abakobo opened 9 years ago

abakobo commented 9 years ago

bug n°1: .visible? returns nil until it's modified once with .visible=

bug n°2: .value= or .visible=(and may be others) will return an error when the UI.messagebox line is not present in the code (tried with sleep 1 second and a for loop - won't work). I found this bug just while writing this example. In larger codes I never had that. My version of Sketchup is 2013 so maybe it's that?

module SKUI_for_my_plugin 
    extension_path = File.dirname( __FILE__ )
    skui_path = File.join( extension_path, 'my_plugin/SKUI' )
    load File.join( skui_path, 'embed_skui.rb' )
    ::SKUI.embed_in( self )
    # SKUI module is now available under SKUI_for_my_plugin::SKUI
end

@options = {
    :title           => 'my_plugin .visible? init bug and early assignement bug',
    :preferences_key => 'my_plugin',
    :width           => 800,
    :height          => 630,
    :resizable       => false
}
@my_plugin_window = SKUI_for_my_plugin::SKUI::Window.new( @options )

@my_plugin_input = SKUI_for_my_plugin::SKUI::Textbox.new( 'hip' )
#txt_input.name = :txt_name
@my_plugin_input.position( 117, 14 )
@my_plugin_input.width = 45
@my_plugin_window.add_control( @my_plugin_input )

@my_plugin_window.show

@resultboxok = UI.messagebox "clickk"  # remove this line to get bug n°2
#sleep 1   #because I tought bug°2 was due to some vars not already created in the interpreter process... but will fail (I tried a for loop too)

puts @my_plugin_input.visible?   #  ----> bug n°1:  returns nil <------

@my_plugin_input.value='hop'  # -----> bug n°2: generates an error (when UI.messagebox is not present) but will change the textbox value! then crashes<-----
@my_plugin_input.visible=true
puts @my_plugin_input.visible?   #now it returns a bool.. (bug n°1)

bug n°2: Console returns: _load "e/el/bug2.rb" nil Error: SKUI::Bridge::CommunicationError: C:/Program Files (x86)/SketchUp/SketchUp 2013/Plugins/e/el/my_plugin/SKUI/bridge.rb:66:in call': Window not visible. C:/Program Files (x86)/SketchUp/SketchUp 2013/Plugins/e/el/my_plugin/SKUI/bridge.rb:66 C:/Program Files (x86)/SketchUp/SketchUp 2013/Plugins/e/el/my_plugin/SKUI/base.rb:130:inupdate_properties' C:/Program Files (x86)/SketchUp/SketchUp 2013/Plugins/e/el/myplugin/SKUI/properties.rb:81:in value=' C:/Program Files (x86)/SketchUp/SketchUp 2013/Plugins/e/el/bug2.rb:34 (eval):76:inload' (eval):76