Using ; (semicolon) list separator in a better way in Tool [Hack]
Symptom:
For example in a native Rectangle Tool or Scale Tool you can type in more values separated by list separator to get desired rectangle or scaling in one step.
However it is not (or not the same way) possible if you are using a certain language (regional) settings and keyboard language, where the list separator is a semicolon ;, and to type in a list separator you need to use Alt Gr (or Ctrl + Alt) + key right side of m.
Here, in the above mentioned Tools, the Ctrl and/or Alt keys are used also as modifier key, therefor pressing them to type in the desired “letter” will modify the Tool behaivor. This one I do not like.
Scale tool animation: Alt Gr ; behavior's
And yes, I know exactly how to handle it with diferent workarouds e.g. type the values after the mouse click, use external keyboard with utility… etc.
But I would like to use it like e.g. English people does.
Certainly the best would be if these native tools can handle the regional setting properly. But since it’s been that way for 20 years or so, I don’t see much of a chance for improvement.
However the gooal is this post to show to the Extension developers one possible way to handle it better. (…perhaps it will also attract the attention of SketchUp developers.)
Idea:
I hope no need too much explanation.
As usual: NO warranties! Use on your own risk!
module Dezmo
module DezmoHackListSeparator
extend self
LIST_SEP ||= Sketchup::RegionalSettings.list_separator
def run
Sketchup.active_model.select_tool( DezmoTypeListSeparator.new )
end
class DezmoTypeListSeparator
def initialize
view = Sketchup.active_model.active_view
reset(view)
end
def reset(view)
@alt_hit = false
@ctrl_hit = false
@usertext = ""
view.invalidate
end
def onCancel(reason, view)
reset(view)
end
def resume(view)
view.invalidate
end
def deactivate(view)
reset(view)
end
def enableVCB?
return true
end
def onUserText(text, view)
@usertext = text
view.invalidate
end
def onKeyUp(key, rpt, flags, view)
puts "onKeyUp: key = #{key}"
if( key == COPY_MODIFIER_KEY )
# Hack to allow entering ; (list separator) to VCB
# using Alt Gr on e.g. HU keyboard)
UI.start_timer(0) { @ctrl_down = false }
return true if @alt_down
@ctrl_hit = !@ctrl_hit
view.invalidate
end
if( key == ALT_MODIFIER_KEY )
# Hack to allow entering ; (list separator) to VCB
# using Alt Gr on e.g. HU keyboard)
UI.start_timer(0) { @alt_down = false }
return true if @ctrl_down
@alt_hit = !@alt_hit
view.invalidate
return true
end
end
def onKeyDown(key, rpt, flags, view)
puts "onKeyDown: key = #{key}"
if( key == COPY_MODIFIER_KEY )
@ctrl_down = true
end
if( key == ALT_MODIFIER_KEY )
@alt_down = true
return true
end
end
def draw(view)
view.draw_text( [10,10], "The current list_separator is #{LIST_SEP}", bold:true )
view.draw_text( [10,30], "Alt hit: #{@alt_hit}", bold:true )
view.draw_text( [10,50], "Ctrl hit: #{@ctrl_hit}", bold:true )
view.draw_text( [10,80], "VCB value: #{@usertext}", bold:true )
end
end #DezmoTypeListSeparator class
end #DezmoHackListSeparator
end #Dezmo
Dezmo::DezmoHackListSeparator.run