Page 1 of 1

solutionModel and Rectangles

PostPosted: Tue Mar 26, 2019 5:25 pm
by tkilshaw1553613063
I am using the solutionModel to generate Servoy screens but have been unable to figure out hos to add a rounded rectangle, or even a plain rectangle to my screen.

Can anyone explain how to do that?

thanks,

Terry

Re: solutionModel and Rectangles

PostPosted: Tue Mar 26, 2019 6:22 pm
by mboegem
Hi Terry,

just use an empty label with borders.
It's not the rectangle you have available at design time, but the closest thing to have.

The rectangle is not exposed in the solutionModel API

Hope this helps.

Re: solutionModel and Rectangles

PostPosted: Tue Mar 26, 2019 6:39 pm
by Joas
Here is some sample code to create a label with a rounded border:
Code: Select all
   var jsForm = solutionModel.getForm(controller.getName());
   
   var jsRectangle = jsForm.newLabel("rectangle", 10, 10, 300, 100);
   jsRectangle.borderType = solutionModel.createRoundedBorder(1,1,1,1, "#000000", "#000000", "#000000", "#000000", [10, 10, 10, 10], null);
   
   controller.recreateUI();

Re: solutionModel and Rectangles

PostPosted: Tue Mar 26, 2019 10:37 pm
by tkilshaw1553613063
Many thanks to Joas and Marc.

It does bed the question as to WHY "The rectangle is not exposed in the solutionModel API"?

cheers,

Terry

Re: solutionModel and Rectangles

PostPosted: Tue Mar 26, 2019 11:24 pm
by tkilshaw1553613063
This worked for me except that the rectangle was opaque.

Seems that you can set its transparent property to true.

Terry

Re: solutionModel and Rectangles

PostPosted: Wed Mar 27, 2019 10:31 pm
by tkilshaw1553613063
So I have my rectangle surrounding some text fields.

The rectangle is transparent so those text fields are visible. But when I try to click on one of those fields the rectangular label gets the click so I can't get to any of the other items inside the rectangle!

Is there a way to do that? To get the label to ignore clicks and let them get to the other items?

thanks,

Terry

Re: solutionModel and Rectangles

PostPosted: Thu Mar 28, 2019 6:32 am
by Joas
Whether an element is on the foreground or not depends on its formIndex-property.
To be in the background, the formIndex of your rectangle needs to be lower than the formIndex of your fields.

Setting it to -1 will probably do the trick:
Code: Select all
jsRectangle.formIndex = -1;

Re: solutionModel and Rectangles

PostPosted: Thu Mar 28, 2019 9:58 am
by rvanderburg
One question. Why do you use solutionmodel?

Re: solutionModel and Rectangles

PostPosted: Thu Mar 28, 2019 10:11 am
by patrick
And it is probably better and easier to maintain to use a styleclass to create the border... Just add a label and assign a styleclass that takes care of its appearance.

Re: solutionModel and Rectangles

PostPosted: Thu Mar 28, 2019 11:28 pm
by tkilshaw1553613063
It was asked "Why do you use solutionmodel?".

We are porting our SnappMX-/Flash-based application to Servoy.

SnappMX provides XML-based screen descriptions. We are generating corresponding Servoy forms using the solution model.

thanks,

Terry