Am Tue, 09 Aug 2022 19:05:22 +0100 schrieb Rob Hemmings:
> It is a long time since I've done any programming on RISC OS and I'd be
> very grateful for a quick bit of advice on something I've forgotten.
>
> Is it possible to change the state of an iconbar icon? I'm writing a
> very simple BASIC program to toggle the state of a system variable and
> I'd like a visual indication of which state it is in. It seems a waste
> to open a separate window just for that so it would be neater to just
> make an alteration to the iconbar icon but I can't remember if that is
> possible?
>
> Thanks in advance for any advice.
It is a long time since You've posted this question ...
but eventually its interesting to You and other folks how this can be done
in a BASIC fragment, which You should be usable in this form:
active% = TRUE
DIM bariconname% 12 : $bariconname% = "active"
baricon%=FNdefine_icon(bariconname%)
wimploop
SYS "Wimp_Poll",pollmask%,pollblock% TO pollevent%
CASE pollevent% OF
WHEN 6 : CASE pollblock%!8 OF
WHEN %100:
active%=NOT(active%) : barmenu%!52=barmenu%!52 EOR %1
IF active% THEN $bariconname%="active" ELSE $bariconname%="nonactive"
block%!0=-2 : block%!4=baricon%
block%!8=0 : block%!12=0
SYS "Wimp_SetIconState",,block%
WHEN %010:
SYS "Wimp_GetPointerInfo",,block%
SYS "Wimp_CreateMenu",,barmenu%,block%!0-60,230
ENDCASE
loopend
DEF FNdefine_icon(name%)
LOCAL width%,hight%,icon%
SYS"Wimp_SpriteOp",40,,$(name%) TO ,,,width%,hight%
block%!0=-1
block%!4=0
block%!8=0
block%!12=width%*2
block%!16=hight%*4
block%!20=%0011000100001010
block%!24=name% : block%!28=1 : block%!32=12
SYS "Wimp_CreateIcon",,block% TO icon%
=icon%
The only thing needed is a !Sprite File with at least two Icons in it
named "active" and "nonactive". This File has to known by the WIMP. The
easiest way to achieve this is by Running an "Iconsprites <Obey$Dir>.!
Sprites" Command in the !Run Obey File.