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 (IDoMethod(bt_group, MUIM_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_group, MUIM_Group_ExitChange);
}
}
[...]
WindowContents, bt_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).
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 ;)
@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".)
"[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().