spinbutton

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
berndg
Posts: 17
Joined: Thu Mar 22, 2012 3:37 pm

spinbutton

Post by berndg » Wed Mar 28, 2012 6:33 pm

Looking at the toolbox: am I right in thinking that I must create spinbuttons myself, from a text entry field and a vertical scrollbar?
Also not sure if there is a way to create one such control once, in a re-usable fashion.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: spinbutton

Post by Klaus » Wed Mar 28, 2012 6:42 pm

Hi Bernd,

pardon my ignorance, but what is a spinbutton?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: spinbutton

Post by dunbarx » Wed Mar 28, 2012 7:59 pm

Klaus.

Do you think it is the old HC beachball?

Craig

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: spinbutton

Post by Klaus » Wed Mar 28, 2012 8:06 pm

Hi Craig,

maybe, not the sligthest idea :D

Hi Bernd,

could you please explain?
But maybe you mean "set cursor to busy"?


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: spinbutton

Post by jmburnod » Wed Mar 28, 2012 10:32 pm

Hi,

Maeby "Spinner store* of René Micout on "Rev on line" is what Bernd want

Best regards

Jean-Marc
https://alternatic.ch

berndg
Posts: 17
Joined: Thu Mar 22, 2012 3:37 pm

Re: spinbutton

Post by berndg » Thu Mar 29, 2012 7:12 am

Well, I'm glad that I contributed to your amusement. I should have explained. By spinbutton, I refer to a text field designated for entry of numeric data, which is accompanied by a pair of up / down arrows for keyboard-less entry. Click the up button to increase the number shown in the edit field, click the down button to decrease the number, or just enter the desired number straight away.

This is the standard user interface tool for numeric data entry on many platforms. Some platforms also support non-numeric, but enumerated, data such as a list of the months of a year.

I admit spinbutton is a generalised term of my own making.

MFC calls it CSpinButtonCtrl
.NET calls it NumericUpDown
Swing calls it Spinner
Delphi calls it SpinEdit
(...)

I am pretty sure LiveCode does not support this construct, but by all means, please let me know if it does.

If LiveCode does not support such a control, the obvious next question would be how to create re-usable custom controls in LiveCode.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: spinbutton

Post by bn » Thu Mar 29, 2012 8:04 am

Hi Bernd,

from the toolbar you drag a "little arrow" object to the card and a text entry field. The little arrow object is technically a scrollbar. Place both objects side by side. You might want change the properties of the text entry field: lockText true, focusable or traversalOn to false (in preferences -> general -> first enty you can set what the properties inspector shows: either description of option or Name of liveCode property. I use the name of the livecode property then it is easier to remember the property for scripting. Anyways the other option will be in the tooltip) Obviously you would want to name your field, I was just lazy and scripted for field 1.
The script of the little arrow object is

Code: Select all

on scrollbarLineInc
  subtract 1 from field 1
end scrollbarLineInc

on scrollbarLineDec
 add 1 to field 1
end scrollbarLineDec
I attach a little stack that shows this.
spinButton.livecode.zip
(1015 Bytes) Downloaded 251 times
and welcome to the forum, now there are two Bernds on the forum and I am not alone anymore :)

Kind regards

Bernd

berndg
Posts: 17
Joined: Thu Mar 22, 2012 3:37 pm

Re: spinbutton

Post by berndg » Thu Mar 29, 2012 8:38 am

Thanks for the info. I figured that much. I take it that there is no way to create reusable custom controls?

I figure I can assign the name of the text field to a custom property of the scrollbar control ("little arrows"), which the scrollBarLineInc and scrollBarLineDec handlers could query. This would at least make the handler code generic (MFC calls this the "buddy control," but I forget if they make the scroll bar the buddy of the text control or vice versa). Other custom properties can be added to the text edit field for numeric minimum value, maximum value, position of decimal point, numeric base (radix), etc.

I have learned enough about LiveCode to do this once for one control. An application dealing with numeric input in such fashion often needs many instances of such a control.

The best I can think of right now is to create the whole thing dynamically, because this allows to define the templateScrollbar and templateField objects once, then create all instances dynamically. Of course, this is no longer RAD GUI development. To that end, I'd place a placeholder control (a button, a label, doesn't really matter) with a special attribute (a custom property or a magic name) on the card. That way, my spin control create handler can tell how many spin controls to create, where to put them, how to size them, and then remove the placeholder piece.

I think this will work for one stack.
It is reusable in other stacks to some extend (that is, if I remember all the little tricks such as the magic designators used with the placeholder controls). It's most certainly not state of the art.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: spinbutton

Post by bn » Thu Mar 29, 2012 8:57 am

Hi Bernd,

what you describe could well be a library in Livecode. A library is a stack and the actual code library is in the stack script. You use your library by issuing a "start using stack "myLibraryStack". This way the stack script of your library stack will be in the message path and accessible.

Or have a look at Ken Ray's DropTools

http://droptools.sonsothunder.com/

That sounds a bit like what would be reusable objects.

His other site is also worth checking
http://www.sonsothunder.com/devres/live ... vecode.htm
lot of tips/tricks, although some of them a bit dated.

Kind regards

Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: spinbutton

Post by bn » Thu Mar 29, 2012 10:21 am

Hi Bernd,

actually there is a free "spinner" for use with dropTools

http://www.sixsides.it/index.php?menu_id=134&lang=eng

It looks the configurable numeric input field you want to do.

Kind regards

Bernd

Post Reply