api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Incorrect `sendAction` Command and Quote Marks in Documentation

Open son-urban opened this issue 9 months ago • 4 comments

Bug Report: Incorrect sendAction Command and Quote Marks in Documentation

Issue:
Sketchup::ModelObserver#onTransactionUndo & #onTransactionRedo The documentation incorrectly suggests using:

Sketchup.sendAction(“editUndo”)
Sketchup.sendAction(“editRedo”)

Issues:

  1. sendAction is outdated; the correct method is send_action.
  2. The action strings require a colon (:) at the end.
  3. The quote marks (“ ”) are incorrect for Ruby; they should be standard double quotes (" ").

Correct Usage:

Sketchup.send_action("editUndo:")
Sketchup.send_action("editRedo:")

Steps to Reproduce:

  1. Run Sketchup.sendAction(“editUndo”) – Error.
Sketchup.sendAction(“editUndo”)
Error: 
#<NameError: undefined local variable or method `“editUndo”' for main:Object>
<main>:in `<main>'
SketchUp:in `eval'

=> nil
Sketchup.sendAction("editUndo:")
Error: 
#<NoMethodError: undefined method `sendAction' for Sketchup:Module
Did you mean?  send_action>
<main>:in `<main>'
SketchUp:in `eval
  1. Run Sketchup.send_action("editUndo:") – it correctly triggers undo.

Suggested Fix:
Update the documentation to use Sketchup.send_action("editUndo:") and Sketchup.send_action("editRedo:"), ensuring correct method names, colons, and quote marks.

son-urban avatar Mar 28 '25 19:03 son-urban

Aside from the documentation issues, please avoid Sketchup.sendAction if possible. It's an API we should have marked deprecated a long time ago.

thomthom avatar Mar 31 '25 10:03 thomthom

Aside from the documentation issues, please avoid Sketchup.sendAction if possible. It's an API we should have marked deprecated a long time ago.

I think since Sketchup.sendAction is not a valid method and raises a NoMethodError (checked back to SU2016), there's no need to worry about deprecating it - it simply doesn't exist.

son-urban avatar Mar 31 '25 12:03 son-urban

I meant Sketchup.send_action.

thomthom avatar Apr 02 '25 08:04 thomthom

Could you clarify why Sketchup.send_action should be avoided? Is it due to potential future deprecation, instability, or another reason? I'm currently using send_action for simple tool selections, like Sketchup.send_action('selectMoveTool:')

Edit: I found your comment on that https://github.com/SketchUp/api-issue-tracker/issues/542#issuecomment-704834945 . Now I get it.

son-urban avatar Apr 02 '25 13:04 son-urban