Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Add tooltip to feature

CAD_SSPCAD_SSP Member Posts: 45 ✭✭
How do you add a tooltip to a feature like the builtin ones?

If you add a "Hole" and hover over "Sketch points to place holes" you get a tooltip saying "No points selected" and on a chamfer if you hover over "Entities to chamfer" you get a tooltip "select edges or faces to chamfer".

I cant locate the tooltip text anywhere in the open source documentation to show how they do it :neutral:

Tagged:

Best Answer

Answers

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited December 2017
    In the source code for hole, on line 224, you'll see the secret sauce:
    throw regenError(ErrorStringEnum.HOLE_NO_POINTS, ["locations"]);
    This aborts the feature with an error, puts one parameter ("locations") in an error state, and provides an error message which is used as the tooltip for that parameter. In the case of hole (a standard feature), a special error key was used (internally, this key will become a different localized message depending on the end user's language, and you can find the English translations for our existing error messages written as comments in errorstringenum.gen.fs ).

    For custom features, you can simply provide an english error message:
    throw regenError("Here's a message describing what's wrong", ["myParameter"]);
    Note that this behavior is specific to error cases (usually those which are present when a user first opens the feature).

    (Whoops, looks like Jake got there first, with a much more thorough explanation. Sorry for the redundancy!) 
Sign In or Register to comment.