PDA

View Full Version : Mimicking the (E)nvelope Button



GregMalick
10-04-2004, 08:04 PM
Envelopes are a great feature in Lightwave. But how can you mimic the Envelope button on the Surface Editor panel? I tried using a ctlstate() but I'm not sure how to keep it "on" until I do a shift-click. I'd prefer a ctlbutton() since I can send a parameter in and make a common module, but I'm not sure how to get that "highlighted" look.

I could use some expert Technical Support. :D

faulknermano
10-05-2004, 01:25 PM
this is prolly a mother of workarounds, but have you tried use reqmouse functions to determine if the shift modifier was used when clicking on the E ctlstate() button?

according to the docs, upon mouse activity, the control identifier can be detected if a control identifier is involved.

but i havent tried this before, so i cant say for sure that it's bound to work.

GregMalick
10-05-2004, 03:19 PM
It's nice to hear from you again, faulknermano. :cool:

I'm thinking the reqmouse() technique will get me halfway there.
But do you know a method to programmatically toggle the ctlstate() on/off?
I need to control the state so that only the shift-click will turn it off.

I've actually been exploring the other option of using a ctlbutton().
Last night I messed around with the drawbox() and drawtext() to change the ctlbutton to look like a ctlstate() when I click on it. Unfortunately, when the mouse is moved off the control, it's repainted to its original grey (off) look.

Any ideas on how to keep that drawbox/drawtext painted on a button? :)

faulknermano
10-05-2004, 03:27 PM
It's nice to hear from you again, faulknermano. :cool:

I'm thinking the reqmouse() technique will get me halfway there.
But do you know a method to programmatically toggle the ctlstate() on/off?
I need to control the state so that only the shift-click will turn it off.



what i had in mind was reqmouse() detecting the shift modifier. if reqmouse() can detect the modifier then you can programmatically control the value of the ctlstate() control, possibly using setvalue(), trying to override the ctlstate() when it tries to toggle it.


I've actually been exploring the other option of using a ctlbutton().
Last night I messed around with the drawbox() and drawtext() to change the ctlbutton to look like a ctlstate() when I click on it. Unfortunately, when the mouse is moved off the control, it's repainted to its original grey (off) look.

Any ideas on how to keep that drawbox/drawtext painted on a button? :)

wow. so you are _committed_ to getting this effect. :D you sort of remind me of myself. haha...

my suggestion, since you're messing around with drawing funcs is to draw the whole button itself, complete with highlight, if you wish. ;) in fact, you can even make your GUI more slick by customising how it's going to look like; you're not limited to the standard lw look. regardless, this is undoubtedly an easier route than combining standard controls with drawing funcs especially when they share the same area, because standard controls are drawn to the requester in a disjunct and less flexible manner from the drawing funcs.

GregMalick
10-05-2004, 04:17 PM
Thanks for the compliment.
I'm committed to having my script behave as LW users probably expect.
I think even mildly experienced users know how the Envelope buttons work and would be totally annoyed by some new method.

Anyway.... setvalue() !!! DOH! :o

I'll check that out tonite. Hopefully it doesn't cause the UDF to be retriggered. That could get real messy, real fast.


Painting my own UI? I can't even paint a UV! hehe ;)
Seriously, that would really hold up the script I'm working on.
I'm hoping your suggestions will cause a breakthough (or maybe breakdown).
If I get something to work, I'll post it here for others to benefit from.

faulknermano
10-05-2004, 04:25 PM
Seriously, that would really hold up the script I'm working on.

it's not really that hard actually. you separate the E button drawing to a single func with arguments to its position in x and y, state, and even to what group it's supposed to belong to (if any). call this func anytime. the once that's down, once you organise it properly the rest is child's play. it'll be much easier later on, i'm almost sure about that. :)

good luck.

GregMalick
10-05-2004, 04:35 PM
If I go this route, we should create an open source LScript library of custom controls. Maybe I'd even get that floating-point mini-slider I've been dreaming of for Christmas. ;)

GregMalick
10-05-2004, 10:17 PM
As I feared, using the setvalue() does indeed retrigger the ctlstate's UDF.
I think it's still codeable, though. :cool:

GregMalick
10-06-2004, 01:04 AM
This almost does the job... but I couldn't detect the Shift with reqmousemove().


e1_UDF: arg1 {

// This is here to intercept the re-execution caused by the setvalue()
if (inProcess==true) return;
inProcess=true;

if (shift)
{
CommandInput("GE_OpenWindow 0");
shift=false;
return;
}

setvalue(e1, true);
CommandInput("GE_OpenWindow 1");
}



reqkeyboard: key {
if (key == REQKB_SHIFT)
shift = true;
else
shift = false;
}

The problem is that you have to shift click in the open area of the requester.
It's as if shift-clicking on the control does not fire the reqkeyboard() routine.

Still a bummer. Anybody have any ideas?