| Author |
Message |
|
Clyde
|
Post subject: #IFOCLASS_OPTIONS Posted: 22 Aug 2008, 08:22 |
|
Joined: 27 May 2008, 19:38 Posts: 67 Location: Dresden / Germany
|
Hi Fabio,
I am not sure, whether this thread is suitable for my post ... Maybe you should add a new thread "Questions" or sth as this is no feature request and no bug report ... Or we just use this thread ... You are the admin, you decide.
Ok, I started using SCUILib for my app and it is a lot of fun!  Thanks for all the work!
Here is my question: I added 8 switches/options to my #IFOCLASS_OPTIONS. Is there a way to count the amount of options in it so that I can iterate through it? Or is this info held somewhere in the table?
EDIT: Ah, and another question: How can I enable/disable an option button with code? With
Code: opts = scui.Get("myOpts") opts.Options[0] I get the first option. But how can I enable/disable it in code? Thanks a lot in advance![/code]
_________________ CD32 + SX1; AmiKit (WinUAE) + OS3.9
|
|
| Top |
|
 |
|
Allanon
|
Post subject: Re: #IFOCLASS_OPTIONS Posted: 22 Aug 2008, 09:09 |
|
| Site Admin |
 |
Joined: 22 Mar 2007, 22:50 Posts: 112
|
Clyde wrote: I am not sure, whether this thread is suitable for my post ... Maybe you should add a new thread "Questions" or sth as this is no feature request and no bug report ... Or we just use this thread ... You are the admin, you decide.  You have posted in the right place don't worry  Clyde wrote: Ok, I started using SCUILib for my app and it is a lot of fun!  Thanks for all the work! Thanks to you for using it  Clyde wrote: Here is my question: I added 8 switches/options to my #IFOCLASS_OPTIONS. Is there a way to count the amount of options in it so that I can iterate through it? Or is this info held somewhere in the table? EDIT: Ah, and another question: How can I enable/disable an option button with code? With Code: opts = scui.Get("myOpts") opts.Options[0] I get the first option. But how can I enable/disable it in code? The first question:In your example you have done Code: opts = scui.Get("myOpts") You can count how many entries you have with Code: options_count = helpers.CountEntries(opts.Options)
because opts.Options contains all option's strings defined in the gadget. The second question:opts.Childs stores all child's id attached to the option object, however you have to pay attention because here you have the option's switches and the labels, you can iterate (and interact) with switches executing a loop like this: Code: Local i For i = 1 To opts.ChildCount Local child_obj = scui.Get(opts.Childs[i]) If child_obj.oClass = #IFOCLASS_SWITCH ; === YOUR CODE FOR THE SWITCH HERE ; DISABLING A SINGLE SWITCH --> scui.Set(opts.Childs[i], { Enabled = #IFODISABLED }, 1)
EndIf Next
Hope this help
P.S.:
opts.Options[0] returns only the string that has been used to define the option text, the first one in this case.
|
|
| Top |
|
 |
|
Clyde
|
Post subject: Posted: 22 Aug 2008, 10:18 |
|
Joined: 27 May 2008, 19:38 Posts: 67 Location: Dresden / Germany
|
Ok, I had several problems, cos I thought you made a typing mistake - I thought the for statement had to be from i = 0, not from i = 1 ... :-/  Why is it 1 not 0?
Ok, the example works now nicely! But, now I see, that I was wrong when stating to disable the buttons. What I want is to change the state of the switch, which means when the switch is pressed (blue highlightened) and I press another button then I want the state of the switch to be unpressed. And vice versa.
I hope you know what I mean:?:
Thanks, mate!
_________________ CD32 + SX1; AmiKit (WinUAE) + OS3.9
|
|
| Top |
|
 |
|
Allanon
|
Post subject: Posted: 22 Aug 2008, 11:19 |
|
| Site Admin |
 |
Joined: 22 Mar 2007, 22:50 Posts: 112
|
mmm...
I've just tried and Childs are supposed to start from index 1 and not 0, infact if I try to start the loop from 0 I get an error that say:
Table field 0 was not initialized
If I've understood what you mean, you have:
- An Options gadget
- You want disable an option that is pressed
- When you press another option you want the disabled option stay pressed
Right?
Well, if the above is right and if the option's selection mode is #OPTMODE_ONLYONE it's normal that the disabled switch will became unpressed when you click another swicth because with this mode only one swicth at a time can be pressed, even if they are disabled.
Try building your options gadget with the tag:
Code: Mode = #OPTMODE_FREE instead of Code: Mode = #OPTMODE_ONLYONE
P.S.: In the example I've written #IFODISABLED instead of #IFO_DISABLED
P.S.S.: I've made the test with the WIP version of ScuiLib, btw I've checked right now that in the older version Childs starts from index 1... If you still have problems I can send to you the WIP version 
|
|
| Top |
|
 |
|
Clyde
|
Post subject: Posted: 22 Aug 2008, 11:28 |
|
Joined: 27 May 2008, 19:38 Posts: 67 Location: Dresden / Germany
|
No, it is no real problem, that it starts with 1, I just wondered.
Ok, I think, I have to improve my English a bit.  I try to explain it with the concrete example I am dealing with:
I have one options gadget, which is #OPTMODE_FREE! I have 8 option buttons in it and everyone can be selected, if it is wanted. Ok, let's assume, that 5 of 8 are selected. Now I want to deselect all the 5 ones! So, what can I do? First I can press each of the 5 buttons separately. But I have implemented a separate "deselect all" and "select all" switch. So, if I press on "deselect all", all pressed options should be deselected, and if I want to select all options at ones I press the "select all" switch.
If it is still hard to understand my crap English  I also could send you the hws, so you see, what I mean.
Thanks a lot!
_________________ CD32 + SX1; AmiKit (WinUAE) + OS3.9
|
|
| Top |
|
 |
|
Allanon
|
Post subject: Posted: 22 Aug 2008, 11:36 |
|
| Site Admin |
 |
Joined: 22 Mar 2007, 22:50 Posts: 112
|
Hoooo! This is really simple!!
If you know that the switches are 8, like in your example, do the following:
SELECT ALL
Code: scui.Set( "myOpts", { Value = { 1,1,1,1,1,1,1,1 } }, 1 ) DESELECT ALL Code: scui.Set( "myOpts", { Value = { 0,0,0,0,0,0,0,0 } }, 1 )
|
|
| Top |
|
 |
|
Clyde
|
Post subject: Posted: 22 Aug 2008, 12:10 |
|
Joined: 27 May 2008, 19:38 Posts: 67 Location: Dresden / Germany
|
Strange, this does not work. Here I also get the error message, that table field 0 is not initialized!? Are you sure it has to be "myOpts" and not opts from the opts = scui.Get("myOpts") statement?
Nevertheless, that doesn't work either.
Besides the problems: Is there a more dynamic way? Maybe it will become more than 8 options ... So I thought this could work (with the for statement), but it doesn't:
Code: scui.Set( opts.Childs[i], { Value = 1 }, 1 )
Help! 
_________________ CD32 + SX1; AmiKit (WinUAE) + OS3.9
|
|
| Top |
|
 |
|
Allanon
|
Post subject: Posted: 22 Aug 2008, 14:21 |
|
| Site Admin |
 |
Joined: 22 Mar 2007, 22:50 Posts: 112
|
Sorry mate,
you are right! There was a bug in ScuiLib 0.5, here is the WIP version so you can continue working on your projects
I've tested the above example with this version and it's working

|
|
| Top |
|
 |
|
Clyde
|
Post subject: Posted: 22 Aug 2008, 14:59 |
|
Joined: 27 May 2008, 19:38 Posts: 67 Location: Dresden / Germany
|
Cool, I found a bug!
Thanks for providing the WIP! But ... if I start my project now I get the following error: table field "multicol" was not initialized! (Line 7819 in ScuiLib.hws, function: newtext) and I can't compile my project anymore now ...
_________________ CD32 + SX1; AmiKit (WinUAE) + OS3.9
|
|
| Top |
|
 |
|
Allanon
|
Post subject: Posted: 22 Aug 2008, 15:07 |
|
| Site Admin |
 |
Joined: 22 Mar 2007, 22:50 Posts: 112
|
|
Yes... because you need this file too, please overwrite your old Default_Standard.hws
^___^'
|
|
| Top |
|
 |
|
Clyde
|
Post subject: Posted: 22 Aug 2008, 15:14 |
|
Joined: 27 May 2008, 19:38 Posts: 67 Location: Dresden / Germany
|
Great!  Works now (after I disabled debug output in default...hws  ). Thanks a lot!
Ok, this works now:
Code: scui.Set( "myOpts", { Value = { 1,1,1,1,1,1,1,1 } }, 1 ) But is there also the dynamical way possible, like: Code: scui.Set( opts.Childs[i], { Value = 1 }, 1 )
EDIT: OT: Did you receive my mail? Also, do you have some kind of chat program up and running from time to time (ICQ, jabber, irc, skype, ...)?
_________________ CD32 + SX1; AmiKit (WinUAE) + OS3.9
|
|
| Top |
|
 |
|
Allanon
|
Post subject: Posted: 22 Aug 2008, 15:47 |
|
| Site Admin |
 |
Joined: 22 Mar 2007, 22:50 Posts: 112
|
Yes, you can change Switch values dynamically without breaking the Options gadget integrity.
Infact when you use...
Code: scui.Set( "myOpts", { Value = { 1,1,1,1,1,1,1,1 } }, 1 ) ...internally a routine iterate trought the switches setting them properly, you can use as model the first example I've posted when I didn't understood what was your question: Code: Local i For i = 1 To opts.ChildCount Local child_obj = scui.Get(opts.Childs[i]) If child_obj.oClass = #IFOCLASS_SWITCH ; === YOUR CODE FOR THE SWITCH HERE scui.Set(opts.Childs[i], { Value = 1 }, 1) EndIf Next
-----
I will check my mail at home, now I'm at work...
about chat programs, at work our firewall block all this chatting programs, so...
at home I don't have any chatting progs, maybe I can reinstall ICQ, do you have some advise about which one I should install? Which one is better? Please don't tell me MSN: I hate this one!!
P.S.: happy to have helped 
|
|
| Top |
|
 |
|
Clyde
|
Post subject: Posted: 22 Aug 2008, 20:31 |
|
Joined: 27 May 2008, 19:38 Posts: 67 Location: Dresden / Germany
|
Great, it works now perfectly! *cheer* I had a small typing mistake first, but through your answer I found the prob. Great, thanks a lot!
Allanon wrote: about chat programs, at work our firewall block all this chatting programs, so... at home I don't have any chatting progs, maybe I can reinstall ICQ, do you have some advise about which one I should install? Which one is better? Please don't tell me MSN: I hate this one!! 
*LOL* Hey, Fabio, I am an Amigan, did you forget?  I would never suggest MSN to you.
Jokes aside, I am not really sure, to be honest. As a GMX ( www.gmx.com/www.gmx.de) I use their GMX Messanger, which works quite ok. But I think, Trillian (Basic) ( http://www.ceruleanstudios.com/) is quite a good prog for that. Let me know, if you need help and/or if you installed it.
But to be honest: I am also not very often online with that progs. It maybe would speed up Q&A a bit if you would also use it.
Maybe in a near distance we could also create an IRC channel for all Hollywood devs ...
_________________ CD32 + SX1; AmiKit (WinUAE) + OS3.9
|
|
| Top |
|
 |