VCB - Input a text string?

hello,
i red some older articles about entering a text in the vcb-value (user text) and learned, that it was not possible to enter letters in the vcb input.

is there - maybe in the latest sketchup versions - a way, to interrupt the shortcut-listener of sketchup, until enter is pressed after the vcb input (esecially for text)?

thanx
stan

First of all, the VCB text can only be read from within a Ruby Tool.

I think that the shortcut problem still exists. You can test with ā€¦

class MyTool

  @@vcb = true

  def self.go
    Sketchup.active_model.select_tool(self.new)
  end

  def activate
    puts "MyTool active."
    @input = ""
  end

  def deactivate(view)
    puts "MyTool deactived."
  end

  def enableVCB?
    return @@vcb
  end

  def getMenu(menu, flags, x, y, view)
    id = menu.add_item('Enable VCB?') {
      @@vcb = !@@vcb
      # reactivate because Sketchup only calls enableVCB? once:
      self.class.go 
    }
    menu.set_validation_proc(id) { @@vcb ? MF_CHECKED : MF_UNCHECKED }
  end

  def onKeyUp(key, repeat, flags, view)
    puts "MyTool: onKeyUp()"
    @input<<key.chr
    puts( key == 13 ? "key: ENTER" : "key: #{key.chr}" )
  end

  # Called only when enableVCB is false and before onKeyUp().
  def onReturn(view)
    puts "MyTool: onReturn()"
    puts "The text input was: #{@input}"
    @input = ""
  end

  # Called only when enableVCB is true and before onKeyUp().
  def onUserText(text, view)
    puts "MyTool: onUserText()"
    puts "The text input was: #{text}"
    @input = ""
  rescue => err
    puts "Invalid entry (#{err.class.name})"
  end

end # class

And then at the console ā€¦

MyTool.go
2 Likes

hi dan, yes,

i have it implemented within a tool, so i came across the problem, than letters assigned to shortcuts will break the input.

but ok, if this is the status quo, we have to live with it.

i use an inputbox for now.

but of course i will try your code - after i understand all of it :slight_smile:

thanx and regards
stan

Iā€™m pretty sure that someone has logged an issue for this.
@Fredo6 perhaps ? NO it was @Neil_Burkholder.

So we are still hopeful that Trimble will add some means to disable Shortcuts when necessary.

You might try using onKeyDown() instead, but I think it still may have issues.
Some keys historically on the Mac have not registered in onKeyDown().

Okay I found the API issue that discussed this problem ā€¦
https://github.com/SketchUp/api-issue-tracker/issues/607

1 Like

oh yes, good discussion.

i also thought of an interrupt for shortcuts, only if something is entered in vcb until enter is pressed.
that would be helpful.

regards
stan