ChangeWorkbenchSelection()

5 posts / 0 new
Last post
mritter0
mritter0's picture
Offline
Last seen: 1 year 10 months ago
Joined: 2014-04-21 21:15
ChangeWorkbenchSelection()

I can get the example code on the AutoDocs wiki to work, but it only gives me the first icon. How do I loop through to get all the icon names in the path? There is no way the example code could compare all the names to "Prefs" the way it is shown.

broadblues
broadblues's picture
Offline
Last seen: 4 years 2 months ago
Joined: 2012-05-02 21:48
The example code looks wrong

The example code looks wrong to me.

It should not be returning BOOL but one of three values.

try something like:

  1. ULONG
  2. SelectPrefs(struct Hook *hook, APTR reserved,
  3. struct IconSelectMsg *ism)
  4. {
  5.  
  6. ULONG result = ISMACTION_Ignore;
  7.  
  8.  
  9. // If the name matches, select it. Otherwise, leave its
  10. // select state alone.
  11. if(Stricmp(ism->ism_Name,"Prefs") == 0)
  12. result = ISMACTION_Select;
  13.  
  14. return(result);
  15. }

[edit]

Raised a BZ against the OS component.

mritter0
mritter0's picture
Offline
Last seen: 1 year 10 months ago
Joined: 2014-04-21 21:15
I saw that too and am using

I saw that too and am using the ignore tag. But I still don't know how to loop through the list of icons. The example shows only comparing the name once.

for(node=GetHead(list); node; node->GetSucc(list)) // or whatever the syntax is
{
....compare names
....return(found it)
}
return(didn't find it)

AND
AND's picture
Offline
Last seen: 6 years 10 months ago
Joined: 2011-01-20 12:22
Your hook is called for each

Your hook is called for each icon inside the drawer, given as the first argument in ChangeWorkbenchSelection().
So, the loop is done by workbench and not by the application.

You can stop the loop, by returning ISMACTION_Stop.

So, lets say the drawer LoopMe has three icons Icon1, Icon2 and Icon3. Then SelectIcon is called three times:

  1. select_hook.h_Entry = (HOOKFUNC)SelectIcon;
  2. ChangeWorkbenchSelection("LoopMe", &select_hook, NULL);
  3.  
  4. SelectIcon() -> IconSelectMsg->ism_Name = Icon1
  5. SelectIcon() -> IconSelectMsg->ism_Name = Icon2
  6. SelectIcon() -> IconSelectMsg->ism_Name = Icon3
mritter0
mritter0's picture
Offline
Last seen: 1 year 10 months ago
Joined: 2014-04-21 21:15
@AND: That is what I thought

@AND: That is what I thought it was supposed to do (and it is). I was totally not catching the names properly. My bad. It works as described. I am doing something totally different than the example.

Log in or register to post comments