position of text and sprite in button
Sergey Lentsov (8268) 63 posts |
Hello, I would like to make button with text and icon but RiscOS always put the sprite icon too close to left/right side (without any space). This is some examples of my attempts: |
Andrew Rawnsley (492) 1445 posts |
I’d pad the sprite with empty space – either grey pixels or (better, assuming it works) mask/transparent pixels. Obviously for an icon like that you only need 16 or 256 colours (maybe less) so there should be minimal size impact. Your other option is to create it as a text or sprite button and overlay a gadget of the other type. Problem then becomes allowing “click through” to the button behind. The final, perhaps least appealing method is to make the button purely a sprite, with the text pre-rendered onto it. I suppose you could do this in RAM to allow a level of internationalisation and use the resulting sprite as a gadget sprite, but that’s hard work. |
Rick Murray (539) 13851 posts |
I’d make it a separate icons, a sprite and the text beside it, and just roll some code to treat them the same regardless of which is actually clicked upon. |
Steve Fryatt (216) 2105 posts |
That’s how CashBook does its sort indicator arrows in its column headings. There’s a mostly-transparent icon that’s placed over the column heading icon for the column that’s currently sorted, and then this code is called in the mouse click handler.
Both of the icons have the same button type, but that’s all they need share. |