Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
141 user(s) are online (93 user(s) are browsing Forums)

Members: 2
Guests: 139

kas1e, balaton, more...

Headlines

 
  Register To Post  

Reaction Label object text changing?
Quite a regular
Quite a regular


See User information
Hi everybody,

I'm writing a Reaction app which needs a slider with 12 values, 0-10 and "AUTO". I'm trying to make a label next to the slider using a Label object, and this works. However, it never updates, even when I call SetAttr or SetGadgetAttr or whatever. I'm using an IDCMP hook for notification.
What should I be doing to get this label working?

Thanks for any help!

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top
Re: Reaction Label object text changing?
Amigans Defender
Amigans Defender


See User information
You have taken the wrong road, traveller Don't use a label to display slider values, use the SLIDER_LevelFormat tag instead. But because sliders only produce numeric values, you will need to setup a slider level hook and provide a hook function to convert the numbers.

First create the hook function that does the conversion:

char *slider_hook_function(struct Hook *hookObject *gadgetstruct TagItem *tags)
{
 static 
char string[8];
 
int32 level IUtility->GetTagData(SLIDER_Level0tags);

 if ( 
level == 11 sprintf(string"AUTO");
 else 
sprintf(string"%d", (int) level);

 return 
string;
}


Then setup the hook:

sliderHook = (struct Hook *)IExec->AllocSysObjectTags(ASOT_HOOK,
                    
ASOHOOK_Entryslider_hook_function,
                    
ASOHOOK_SubentryNULL,
                    
ASOHOOK_DataNULLTAG_END);


In your GUI creation code, the slider gadget definition must include the following tags:

GA_RelVerifyTRUE,
SLIDER_Min0,
SLIDER_Max11,
SLIDER_LevelFormat"%s",
SLIDER_LevelHooksliderHook,
SLIDER_LevelMaxLen6,


The slider will display the labels automatically, the value conversion (11 = AUTO) is done by your hook function.

Of course, when you're done with your program you must free the hook because hooks are system resources:

if (sliderHookIExec->FreeSysObject(ASOT_HOOKsliderHook);


The Rear Window blog

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
Go to top
Re: Reaction Label object text changing?
Quite a regular
Quite a regular


See User information
Excellent! Thanks for that - I did wonder if I was barking up the wrong tree but there's scant little documentation to work with.

This is exactly the sort of entry that should go in the new AmigaOS developers wiki! :)

--
Ian Gledhill
ian.gledhill@btinternit.com (except it should be internEt of course...!)
Check out my company's shop: http://www.mutant-caterpillar.co.uk/shop/ - specialising in Sinclair Spectrums but will be adding Amigas!
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project