Page 1 of 1

Ruby In-place Edit Controls

PostPosted: Wed May 15, 2019 3:15 pm
by DaveyBoy
Quoting the manual:

Edit controls are pretty much essential for gathering precise numerical or text input. You can create an
in place edit control on-the-fly whenever you need to get information by using the createEdit method:
createEdit input, id, area, [startText [,font [,textColour
[,backColour [,multiline]]]]]
The inputs to the method are as follows:
input - reference to the input View connector (name or index)
id - an id that you can use on the callback so you know which edit is reporting
area - four element array [x,y,w,h] to define position and size
startText - the text that will show in the edit to start with [OPTIONAL]
font - the font to use (a font object) [OPTIONAL]
textColour - the colour of the text [OPTIONAL]
backColour - the colour of the background rectangle for the edit control [OPTIONAL]
multiline - whether the control should be a multiline edit (true or false) [OPTIONAL]


This seems to work fine without the array brackets up to and including the Font option.
I can't get the textColour, backColour and multiline options to work though.

The commas are obviously in the wrong place but I still can't get these options to work no matter what I try.

Has anyone got any ideas how to get this to work or am I missing something simple? (wouldn't be the first time :))

Also the position has to be adjusted to be in the same location as the original text but I can live with that.

Thanks in advance for any help
Dave

Re: Ruby In-place Edit Controls

PostPosted: Wed May 15, 2019 3:19 pm
by wlangfor@uoguelph.ca
I'll take alook

Re: Ruby In-place Edit Controls

PostPosted: Fri May 17, 2019 2:32 pm
by wlangfor@uoguelph.ca
will look today, I've been busy.

As well, promised to make something that makes circular text.

:)

Re: Ruby In-place Edit Controls

PostPosted: Fri May 17, 2019 11:51 pm
by DaveyBoy
Appreciate you taking a look . . Cheers

Re: Ruby In-place Edit Controls

PostPosted: Sat May 18, 2019 9:33 pm
by DaveyBoy
Finally sorted it.

I was defining the colours with pens and brushes when it should be just RGB Data: (Color.new n,n,n) :mrgreen:

There are no brackets as shown in the manual . . . just comma separated values :)

Re: Ruby In-place Edit Controls

PostPosted: Sat May 18, 2019 11:46 pm
by tulamide
DaveyBoy wrote:Finally sorted it.

I was defining the colours with pens and brushes when it should be just RGB Data: (Color.new n,n,n) :mrgreen:

There are no brackets as shown in the manual . . . just comma separated values :)

Oh, yes, when creating the color object right in the code line, you have to be careful!
I suggest to always use brackets to enclose arguments. That way you see issues way earlier.
Code: Select all
Color.new(a, r, g, b)

Color definition can be made by passing various amounts of arguments:
Code: Select all
Color.new(g) # g = grey value
Color.new(a, g) # like above plus alpha channel
Color.new(r, g, b) # red, green, blue
Color.new(a, r, g, b) # like above plus alpha channel


You mean the edgy brackets? []
Those tell you at what point data is optional.
For example, this is valid
Code: Select all
createEdit(myinput, myid, myarea)

Or this
Code: Select all
createEdit(myinput, myid, myarea, "Type here", myfont)

But not this
Code: Select all
createEdit(myinput, myid, myarea,mybackcolor)

If you want to have a back color defined, you also have to pass startText, font and textColour

It'S easiest to read such instructions from right to left: You can leave out "multiline" OR "backColour" and "multiline" OR "textColour" and "backColour" and "multiline", etc.

Re: Ruby In-place Edit Controls

PostPosted: Sun May 19, 2019 12:59 pm
by wlangfor@uoguelph.ca
DaveyBoy wrote:Finally sorted it.

I was defining the colours with pens and brushes when it should be just RGB Data: (Color.new n,n,n) :mrgreen:

There are no brackets as shown in the manual . . . just comma separated values :)


Oh? ah yes I find that confusing too. Should be universal. Well, glad You solved it. I've had a cold or something.

Re: Ruby In-place Edit Controls

PostPosted: Sun May 19, 2019 1:20 pm
by DaveyBoy
Thanks for the info Tulamide, it's all becoming clear now, it's the brackets in the manual that threw me off the scent . . . but I get it now.

wlangfor, not to worry, we got there in the end.

Thanks again guys :)