How to get the coordinate of cursor when click left botton ?

Hello Matthias,

Wish you and K-layout team have a great 2025, and also hope to see more functions of art this year. :)
Now I am trying to develop a simple routing feature by myself, but I can't find out how to get the coordinate of cursor while click the left button.

A simple hint woulld be appreciated.

Vincent

Comments

  • edited January 7

    Hello Matthias,

    I found the relative topic but disscussed in Python, I put it into Ruby as below,
    but I would like to ask two more questions if passible

    1 ) After macro is run, the measurement cursor setting seems to be initialized ?

    2 ) How to achieve the black outline of simulated path and just pressed " ctrl " could force it turn to 45 degree or perpendicular ?

    I wonder question 2 ) may not easy to explain, please ignore if it's a long story :)
    ( it should be relatived to Pcell things :/ )

    class PluginTestFactory < RBA::PluginFactory
    
      # Constructor
      def initialize
        # registers the new plugin class at position 100000 (at the end), with name
        # "my_plugin_test" and title "My plugin test"
        register(100000, "my_plugin_test", "My plugin test")
      end
    
      # Create a new plugin instance of the custom type
      def create_plugin(manager, dispatcher, view)
        return PluginTest.new
      end
    
    end
    
    # The plugin class
    class PluginTest < RBA::Plugin
      def mouse_moved_event(p, buttons, prio)
        if prio
          # Set the cursor to cross if our plugin is active.
          set_cursor(RBA::Cursor::Cross)
        end
        # Returning false indicates that we don't want to consume the event.
        # This way for example the cursor position tracker still works.
        false
      end
      def mouse_click_event(p, buttons, prio)
        if prio
          puts p  # this line might be weird a bit
          # This indicates we want to consume the event and others don't receive the mouse click
          # with prio = false.
          return true
        end
        # don't consume the event if we are not active.
        false
      end
    end
    
    # Instantiate the new plugin factory.
    PluginTestFactory.new
    

    Thanks
    Vincent

Sign In or Register to comment.