Issues with bodywidth and pos settings on panel controls
jjweimer
I am trying to understand why this does not work as I might expect. Run these on the command line:
// create panel
NewPanel
// add button
PopupMenu test pos={10,40},bodyWidth=0,title="SomeThing",value="One;Two;"
// set the body width
PopupMenu test pos={10,40},bodywidth=200
// --> WHY DOES THE BUTTON NOT ADHERE TO THE POSITION SETTINGS????
// try this instead
PopupMenu test align=0,pos={10,40},bodywidth=200
// now it forces the position, but I thought the default was align=0????
NewPanel
// add button
PopupMenu test pos={10,40},bodyWidth=0,title="SomeThing",value="One;Two;"
// set the body width
PopupMenu test pos={10,40},bodywidth=200
// --> WHY DOES THE BUTTON NOT ADHERE TO THE POSITION SETTINGS????
// try this instead
PopupMenu test align=0,pos={10,40},bodywidth=200
// now it forces the position, but I thought the default was align=0????
I am having particular difficulty with this type of code inside a function call to create a panel. It seems that even when I use the align=0 setting, the position is not respected.
Am I missing something simple in how I should run this instead?
Igor Pro 8 on macOS.
It is surprising. I suspect there's a bug in there somewhere, but the interactions of all the various sizing options are byzantine to say the least.
The align keyword actually has nothing to do with it. What fixes the problem is the repetition of the pos={} keyword. The following sequence results in what you want:
•// add button
•PopupMenu test pos={10,40},bodyWidth=0,title="SomeThing",value="One;Two;"
•// set the body width
•PopupMenu test pos={10,40},bodywidth=200
•PopupMenu test pos={10,40},bodywidth=200
as does this:
•// add button
•PopupMenu test pos={10,40},bodyWidth=0,title="SomeThing",value="One;Two;"
•// set the body width
•PopupMenu test bodywidth=200
•PopupMenu test pos={10,40}
And if you save the recreation macro from the version that is laid out the way you want, somehow magically it works right:
PauseUpdate; Silent 1 // building window...
NewPanel /W=(150,50,450,250)
PopupMenu test,pos={10.00,40.00},size={252.00,20.00},bodyWidth=200,title="SomeThing"
PopupMenu test,mode=1,popvalue="One",value= #"\"One;Two;\""
EndMacro
I have spent more hours than I care to admit working on twitchy problems like this. Every time I fix one thing, something else pops out at the other end. I recall specifically spending quite a bit of time making sure that the recreation macro actually does the right thing.
Sorry for that bitter little complaint :) Yes, it sure seems like a bug. No, I don't think I can fix it, but there's a work-around. My apologies.
March 30, 2020 at 11:25 am - Permalink
John: Thanks. I am glad enough for the work around. No apologies needed. — Jeff
March 30, 2020 at 01:30 pm - Permalink
Well, I feel bad saying that I can't fix something because it's too complicated. Feels like cheating for a professional. But in fact, Igor is a monster application with more complexities than you can shake stick (or fist) at. Glad I could at least provide the work-around.
March 30, 2020 at 02:59 pm - Permalink
Just a quick thought ... Add a note in the documentation that the combined use of pos={...} and bodywidth=... can give un-expected results. The example that you posted is a good reference to remind those facing it in the future.
And I am not shaking a stick or my fist anytime at Igor Pro. It has been far too good in far too long a service to my research and teaching needs to grumble over minor problems such as this.
March 30, 2020 at 03:43 pm - Permalink