Using OnRbuttonDown twice in a tool

Dear all,

I’m sure that someone will help me. All your support will be appresciated.

I wrote a tool that offset and round a line drawned by the user and now I want to copy it in series.

I simply collect the picked vertex using “OnRbuttonDown” and than generate the new line. Now I need to copy in series the new line selecting the path along wich copy all the instancies. Trying to develop this second step, I thought to use again “OnRbuttonDown” but it is just in use in the first step, so this action make little confused. Is it possible to use “OnRbuttonDown” consecutivelly in the same tool? Maybe I need to include it in a module and call this module in the tool?
Attached a video to better understand what I want to do.

Thank you to all who wants to help me

Yes.

Your tool needs to keep the state (or step) number. The initial state @state before the first point is picked is usually set to 0. After a valid point is picked, your code needs to increment the @state variable by 1.

Then in your onRButtonDown callback you check the @state variable value and do what is required.

case @state
when 0
  # initial state, check for valid inputpoint
  # if valid save the point and set @state to 1
when 1
  # This is the second right button click
  # so do the next step in the tool
when 2
  # etc., etc.
end

When the final step is done call a reset method that (among other things) would reset the @state variable to 0. (This method can also be called by the tool’s activate callback method.)

2 Likes

Note that using the Right Mouse Button, your tool may be fighting with the context menu.

See the open issue in the API bug tracker:

Thank you very much Dan, your support is always appresciated. I will follow your suggestion and come back to you as soon as I can!!

1 Like

Hello Dan,

I want to thank you for your support!! Now everything works as I wants. Just a correction to my question, I was referring to onLbuttonDown!!

1 Like

Ah okay. Yes the left button is the normal pick button (for right-handed persons.)