Trying to access right click menu with no selection

Well, we do call it a context menu.

But yes, there is no explicit context to commands as nothing is selected to give them context.

I have already reported this. I previously logged this as Issue 809 in API Issue Tracker.

There actually is what we can call a “implicit model context” when there is no selection and that this implicit context is the top-level model entities collection.

Evidence that the Invert Selection command actually becomes a Select All command and selects everything at the top-level of the model.

I can’t remember offhand what it was I thought would be nifty on such a no selection context menu. (I’ll sleep on it.)

It actually does not have a conditional to ensure it shows when the selection is empty. I.e.:

  module RtClick
    if !defined?(@ui_loaded)
      UI.add_context_menu_handler do |menu|
        if Sketchup.active_model.selection.empty?
          menu.add_item("It's Empty") {
            UI.messagebox('Really Empty!')
          }
        end
      end
    end
  end

But it still does not appear when the selection is empty.

Weirdly it does with a right-click on any axis.

1 Like