Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
How do I add buttons to a UI window like the ones in Routing Curve?
How do I add buttons to a UI window like the ones in Routing Curve?
I tried to look at the code, but it links to something that I cant seem to access.
Best Answer
-
GregBrown Member, Onshape Employees, csevp Posts: 211
I'll send you one example, and clean it up to share for the rest of the forum… But for now:
In the predicate for the feature you can create a button type like:
annotation { "Name" : "My Button" } isButton(definition.doSomething);
Also you need to include a new parameter in your editing logic function, so the function definition looks something like this:
export function myEditLogic(context is Context, id is Id, oldDefinition is map, definition is map, isCreating is boolean, specifiedParameters is map, hiddenQueries is Query, clickedButton is string) returns map { //do stuff // … if (clickedButton == "doSomething") { definition.count = oldDefinition.count + 1; return anotherFunctionPerhaps(context, id, definition); } //… return definition; }
When you "do stuff" you'll need to check for clickedButton (remember it will be a string) then… do something!
2
Answers
I'll send you one example, and clean it up to share for the rest of the forum… But for now:
In the predicate for the feature you can create a button type like:
Also you need to include a new parameter in your editing logic function, so the function definition looks something like this:
When you "do stuff" you'll need to check for clickedButton (remember it will be a string) then… do something!
Thank you, this can be a solution for a few different UI needs...
Now if only my real work would slow down enough for me to just sit and code for a while