Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
100 user(s) are online (82 user(s) are browsing Forums)

Members: 0
Guests: 100

more...

Support us!

Headlines

 
  Register To Post  

MUI : help for SimpleButton (shortcut and width)
Just can't stay away
Just can't stay away


See User information
Hi,
i need help (again, sorry to ask you so often...) to make a MUI GUI.

I have 2 questions concerning SimpleButton

1) Width fixed problem :

How to make a width fixed button ?
If I have a button with a text "TEST" at initialisation, my MUI button will reserve this space, but if change text "TEST" to "ANTICONSTITUTIONNELLEMENT",
the second text will be truncated... Of course. I just want to know if it's possible to make a width reservation for a SimpleButton ???
I want for example to reserve a 40 characters buttons with a "test" string at middle...

2) Shortcut problem :

I have a SimpleButton with text "_Push me XXXXXXX".
=> Child, bt_test = SimpleButton("_Push me XXXXXXX"),

When I launch my program all is great, the P shortcut is working.

When I push this button, I make a Notify to change his TextContent to
"_Push...ed with long string" by set(bt_test,MUIA_Text_Contents,"_Push...ed with long string");

The problem is here, the text button is showing the "_" and the shortcut is no more working...

If somebody interested, my problem is
http://zzd10h.amiga-ng.org/Divers/MUI/1.jpg
http://zzd10h.amiga-ng.org/Divers/MUI/2.jpg

and the sample program is :
http://zzd10h.amiga-ng.org/Divers/MUI/test.lha (including source sample and make file)

thank for help...
zzd10h


Edited by zzd10h on 2012/12/29 23:28:49
Go to top
Re: MUI : help for SimpleButton (shortcut and width)
Just popping in
Just popping in


See User information
@1) Width fixed problem:
[...]
Object *bt_group, *bt_test, *bt_nothing1, *bt_nothing2;
[...]
void hook_boutontestFunc(struct Hook *hook,APTR obj)
{
    
//printf("Button pressed\n");    
    
    
if (IDoMethod(bt_groupMUIM_Group_InitChange))
    {
        if (
TEST)
        {
            
set(bt_test,MUIA_Text_Contents,"Push...ed with long string");
        }
        else
        {
            
set(bt_test,MUIA_Text_Contents,"Push Me");
        }
        
TEST = !TEST;
        
IDoMethod(bt_groupMUIM_Group_ExitChange);
    }
}
[...]
                
WindowContentsbt_group VGroup,
[...]


@2) Shortcut problem :

Looks like the shortcut is only support at object creation time. You could create a new button and remove the old one (see MUI_Group.doc/MUIM_Group_InitChange) or do the underlining yourself (see MUI_Text.doc/MUIA_Text_Contents).

Go to top
Re: MUI : help for SimpleButton (shortcut and width)
Just can't stay away
Just can't stay away


See User information
Thank you Gazelle,
For 1) I bad explained the problem... My wish was to have a fixed width group of buttons for various contents size.
For example, the 3 buttons have a 20 char size with
button 1 text "toto"
button 2 text "tutu"
button 3 text "azertyuiop"
and that It was persistent even after a iconify/uconify.
I have solved this problem by padding the Contents to reach a fixed size, each time that I change my button text.

For 2) I have tried to use MUIA_Text_HiChar and MUIA_ControlChar
with set(bt_Test,MUIA_ControlChar,'P') and set(bt_Test,MUIA_Text_HiChar,'P') without success
I tried too, to use
DoMethod(bt_group,OM_REMMEMBER,bt_test);
and
DoMethod(bt_group,OM_ADDMEMBER,bt_test);
without success.
I have maybe to learn how to Dispose, AddNewObject.

Thank you Gazelle, to have took time to answer me. And thank you Thore, too, to have responded to my mails ;)


Edited by zzd10h on 2013/1/3 0:08:10
Go to top
Re: MUI : help for SimpleButton (shortcut and width)
Just can't stay away
Just can't stay away


See User information
I made others tests and finally the 2 points are working.

1) I finally use MUIA_FixWidthTxt (thank Thore)
char bigpadding[40]="01234567890...6789";
set(bt_nothing1,MUIA_FixWidthTxt,bigpadding);
set(bt_test,MUIA_FixWidthTxt,bigpadding);
set(bt_nothing2,MUIA_FixWidthTxt,bigpadding);

just after the CreateGUI

2) For the shortcuts it works simply with TextHiChar and ControlChar with \33u for the display)

void hook_boutontestFunc(struct Hook *hook,APTR obj)
{
if (TEST)
{
set(bt_test,MUIA_Text_HiChar, 'v');
set(bt_test,MUIA_ControlChar, 'v');
set(bt_test,MUIA_Text_Contents,"\33uV\33nery big button with lot of characters");
}
else
{
set(bt_test,MUIA_Text_HiChar, 's');
set(bt_test,MUIA_ControlChar, 's');
set(bt_test,MUIA_Text_Contents,"\33uS\33nmall");
}
TEST = !TEST;
}

I have reuploaded the sample
http://zzd10h.amiga-ng.org/Divers/MUI/test.lha

I'm happy ;)

Thank again, Gazelle and Thore !

Go to top
Re: MUI : help for SimpleButton (shortcut and width)
Home away from home
Home away from home


See User information
@zzd10h
For fixed button width, you need to replace SimpleButton() with the MUI code that it's macro produces, then you can modify it to have a fixed width. So something like this (untested) :

GroupObject, MUIA_Background,MUII_ButtonBack, MUIA_Frame,MUIV_Frame_Button, MUIA_InputMode,MUIV_InputMode_RelVerify, MUIA_FixWidth,myWidthInPixels, Child,FreeLabel(myLabel), End

You may need to add padding around FreeLabel(), in which case it would get a bit more complex. And/or you may need to expand the FreeLabel() macro & move the MUIA_FixWidth in there instead.

Also, I am specifying the width in pixels, but you can use MUIA_FixWidthTxt instead if you want it to fit the width of a particular string (characters are not of fixed width, so you can't just say "20 chars".)

Author of the PortablE programming language.
Go to top
Re: MUI : help for SimpleButton (shortcut and width)
Just popping in
Just popping in


See User information
@zzd10h:

from MUI_Text.doc:
Quote:
MUIA_Text_HiChar -- (V4 ) [I..], char


"[I..]" means it can only be used at object creation time and can NOT be set.
And as you do the underlining yourself it's not necessary.

from libraries/mui.h:
Quote:
** MUIA_... attribute definitions are followed by a comment
** consisting of the three possible letters I, S and G.
** I: it's possible to specify this attribute at object creation time.
** S: it's possible to change this attribute with SetAttrs().
** G: it's possible to get this attribute with GetAttr().

Go to top
Re: MUI : help for SimpleButton (shortcut and width)
Just can't stay away
Just can't stay away


See User information
@gazelle :
Right !
MUIA_Text_HiChar is not necessary,
I have just tested, and I just need \33uX\33n and MUIA_ControlChar

@ChrisH
Thanks you,
my need is just to have the same width for 3 buttons in the same group, therefore MUIA_FixWidthTxt is sufficient for my need,

Go to top
Re: MUI : help for SimpleButton (shortcut and width)
Home away from home
Home away from home


See User information
@zzd10h

Quote:
I made others tests and finally the 2 points are working.


Cool so we can finally re-add our shortuts

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-2024 The XOOPS Project