Skip to content

Commit

Permalink
Prevent "o" key from displaying the output window while the textfield…
Browse files Browse the repository at this point in the history
… has the focus
  • Loading branch information
fieldOfView committed May 20, 2011
1 parent a97068d commit 4510b03
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions textfieldex/src/textfieldex.as
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ package
txt.removeEventListener(MouseEvent.CLICK, click_event);
txt.removeEventListener(FocusEvent.FOCUS_IN, focusin_event);
txt.removeEventListener(FocusEvent.FOCUS_OUT, focusout_event);
txt.removeEventListener(KeyboardEvent.KEY_DOWN, keydown_event);

// remove krpano event listeners
krpano.removePluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
Expand Down Expand Up @@ -332,6 +333,8 @@ package
// disable keyboard navigation while editing text
usercontrol = krpano.get("control.usercontrol");
krpano.set("control.usercontrol", (usercontrol=="all" || usercontrol=="mouse")?"mouse":"off");

txt.addEventListener(KeyboardEvent.KEY_DOWN, keydown_event);

if (pluginobj.onfocus != null)
{
Expand All @@ -343,13 +346,36 @@ package
{
// reenable keyboard navigation
krpano.set("control.usercontrol", usercontrol);

txt.removeEventListener(KeyboardEvent.KEY_DOWN, keydown_event);

if (pluginobj.onblur != null)
{
krpano.call(pluginobj.onblur);
}
}

private function keydown_event(event:KeyboardEvent):void
{
switch(event.keyCode)
{
case 79:
// 'o'; inhibit showing/hiding the output window
event.stopPropagation();
break;
case 13:
// enter; if single line, call submit action
if(!txt.multiline)
{
if (pluginobj.onsubmit != null)
{
krpano.call(pluginobj.onsubmit);
}
}
break;
}
}

private function updateSTYLE():void
{
// pass the krpano parameters to the as3 textfield
Expand Down

0 comments on commit 4510b03

Please sign in to comment.