action callback function not working in sketchup

12 Views Asked by At

I’m new to sketchup, ruby sdk and I’ve run into a problem while creating a simple extension, I can’t seem to make the action callback work, so basically there is a input textbox and on pressing the enter key the text should get appended to a list. I defined this action callback in the ruby code named ‘enter_pressed’

def self.show_dialog
        if @dialog && @dialog.visible?
          @dialog.bring_to_front
        else
          @dialog ||= self.create_dialog
          @dialog.add_action_callback('enter_pressed') do |action_context|
            on_enter_pressed
            puts 'This is a debug message'
            nil

          end

          @dialog.show
        end
      end
    end

    def self.on_enter_pressed 
      puts 'Enter key pressed'
      ChatHandler.sendMessage
    end

and this is the js code calling the ruby function

class InteractionHandler{
 
 
    static checkEnter(event) {
        if (event.key === "Enter"){
          sketchup.action_callback("enter_pressed");
        }
      }

}

And this is the html code

<input type="text" id="input-message" placeholder="Type your message..." onkeyup="InteractionHandler.checkEnter(event)"
0

There are 0 best solutions below