Hi guys..
I am just adding a Flex HSlider to my dialog. It allows for setting a time duration in days, and I thought it would be great if the user can snap to weeks by pressing the SHIFT key while dragging the slider.
Unfortunately the event passed to the event-handler contains no key modifier information..
Here is my code:
protected function onDurationSliderChange (event:SliderEvent) : void
{
var durationInDays : int = this.sld_durationInDays.value;
// modifiers
if (event.triggerEvent is MouseEvent) {
var mouseEvt : MouseEvent = event.triggerEvent as MouseEvent;
trace (mouseEvt.ctrlKey + " " + mouseEvt.ctrlKey + " " + event.keyCode);
trace (mouseEvt);
// when using SHIFT, snap to week
if (mouseEvt.shiftKey && !mouseEvt.ctrlKey)
durationInDays = int(durationInDays/7) * 7;
}
this.durationInDays = durationInDays;
}
which produces the following output:
false false -1
[MouseEvent type="click" bubbles=true cancelable=false eventPhase=2 localX=NaN localY=NaN stageX=NaN stageY=NaN relatedObject=null ctrlKey=false altKey=false shiftKey=false buttonDown=false delta=0]
Anybody got an idea how to find out if SHIFT (or CTRL) was pressed while dragging? Thanks!