Skip to main content
tropicanaclock
Known Participant
February 19, 2013
Question

VIRTUAL KEYBOARD SpaceKey not autosizing

  • February 19, 2013
  • 1 reply
  • 656 views

Hello, So my space button wont autosize on the virtual keyboard. It creates the blank space but doesnt autosize to it, after inputing any other key it autosizes correctly. Could use an extra set of eyes to see what im doing wrong

Ill post any relevant code down here

//spaces;

key_space.addEventListener(MouseEvent.CLICK, spaceClickListener);

function spaceClickListener(e:MouseEvent):void

{

          if (control == "on" && menu.visible == false )

          {

                    strehrows3();

                    textSelect.appendText(" ");

                    shift = false;

                    //border control;

                    if (textSelect.width <= 134.05)

                    {

                              // textSelect.autoSize = TextFieldAutoSize.RIGHT;

                              textSelect.x = 1.2;

                    }

                    if (textSelect.width >= 134.05)

                    {

                              ///textSelect.autoSize = TextFieldAutoSize.RIGHT;

                              textSelect.x =  1.2-(textSelect.width-134.05);

                    }

                    //inputTxt.autoSize = TextFieldAutoSize.NONE;

                    textSelect.setSelection(textSelect.length,textSelect.length);

          }

                    focuser();

                    strehrows3();

                    _fontSize();

}

function _keys(event:MouseEvent):void

{

          strehrows3();

          textSelect.setSelection(textSelect.length,textSelect.length);

          if (electoff.currentFrame == 2)

          {

                    ajWidth(event);

          }

          if (terminalinput.currentFrame == 2)

          {

                    TrWidth(null);

          }

          if (control == "on" && menu.visible == false )

          {

                    if (! shift)

                    {

                              textSelect.appendText(letterButtonSmall[event.target.name]);

                    }

                    else

                    {

                              textSelect.appendText(letterButtonCaps[event.target.name]);

                              shift = false;

                    }

                    savedTxt = textSelect.text;

                    textSelect.setSelection(textSelect.length,textSelect.length);

                    if (textSelect.width <= 134.05 && textSelect == inputClips.inputTxt )

                    {

                              textSelect.autoSize = TextFieldAutoSize.RIGHT;

                              textSelect.x = 1.2;

                    }

                    if (textSelect.width >= 134.05 && textSelect == inputClips.inputTxt)

                    {

                              textSelect.autoSize = TextFieldAutoSize.RIGHT;

                              textSelect.x =  1.2-(textSelect.width-134.05);

                    }

          }

          textSelect.setSelection(textSelect.length,textSelect.length);

          if (electoff.currentFrame == 2)

          {

                    ajWidth(event);

          }

          if (terminalinput.currentFrame == 2)

          {

                    TrWidth(null);

          }

 

                    focuser();

                    strehrows3();

                    _fontSize();

}

This topic has been closed for replies.

1 reply

Inspiring
February 19, 2013

if the lower function is responsible for handling all the other virtual keyboard input events, and the above function that handles the keyboard event is only working as expected if the lower function triggers first, then you will have to look for the things they differ from each other.

These lines

          if (electoff.currentFrame == 2)

          {

                    ajWidth(event);

          }

          if (terminalinput.currentFrame == 2)

          {

                    TrWidth(null);

          }

are missing in the above function, so it could be something in either of these two functions ajWidth,TrWidth, that kickstarts the autoresizing.

At this point -without seeing the whole code it starts to become a wild goose chase ;-)

tropicanaclock
Known Participant
February 19, 2013

Fair Enough Ill give it a go. Next time I'll try to make it a little eaiser on you guys with the code.

tropicanaclock
Known Participant
February 20, 2013

Been struggling with this, I now made the space function nearly identical to my keyboard function.

Pressing the space key doesnt autoformat the text for some reason Im having trouble understanding, it adds the space but wont show up until I enter an actual letter or number.

function _keys(event:MouseEvent):void

{

          strehrows3();

          textSelect.setSelection(textSelect.length,textSelect.length);

          if (electoff.currentFrame == 2)

          {

                    ajWidth(event);

          }

          if (terminalinput.currentFrame == 2)

          {

                    TrWidth(null);

          }

          if (control == "on" && menu.visible == false )

          {

                    if (! shift)

                    {

                              textSelect.appendText(letterButtonSmall[event.target.name]);

                    }

                    else

                    {

                              textSelect.appendText(letterButtonCaps[event.target.name]);

                              shift = false;

                    }

                    savedTxt = textSelect.text;

                    textSelect.setSelection(textSelect.length,textSelect.length);

                    if (textSelect.width <= 134.05 && textSelect == inputClips.inputTxt )

                    {

                              textSelect.autoSize = TextFieldAutoSize.LEFT;

                              textSelect.x = 1.2;

                    }

                    if (textSelect.width >= 134.05 && textSelect == inputClips.inputTxt)

                    {

                              textSelect.autoSize = TextFieldAutoSize.LEFT;

                              textSelect.x =  1.2-(textSelect.width-134.05);

                    }

          }

          textSelect.setSelection(textSelect.length,textSelect.length);

          if (electoff.currentFrame == 2)

          {

                    ajWidth(event);

          }

          if (terminalinput.currentFrame == 2)

          {

                    TrWidth(null);

          }

                    focuser();

                    strehrows3();

                    _fontSize();

}


//spaces;

key_space.addEventListener(MouseEvent.CLICK, spaceClickListener);

function spaceClickListener(e:MouseEvent):void

{

          strehrows3();

          textSelect.setSelection(textSelect.length,textSelect.length);

          if (electoff.currentFrame == 2)

          {

                    ajWidth(null);

          }

          if (terminalinput.currentFrame == 2)

          {

                    TrWidth(null);

          }

          if (control == "on" && menu.visible == false )

          {

                    if (! shift)

                    {

                              textSelect.appendText(" ");

                    }

                    else

                    {

                              textSelect.appendText(" ");

                              shift = false;

                    }

                    savedTxt = textSelect.text;

                    textSelect.setSelection(textSelect.length,textSelect.length);

                    if (textSelect.width <= 134.05 && textSelect == inputClips.inputTxt )

                    {

                              textSelect.autoSize = TextFieldAutoSize.LEFT;

                              textSelect.x = 1.2;

                    }

                    if (textSelect.width >= 134.05 && textSelect == inputClips.inputTxt)

                    {

                              textSelect.autoSize = TextFieldAutoSize.LEFT;

                              textSelect.x =  1.2-(textSelect.width-134.05);

                    }

          }

          textSelect.setSelection(textSelect.length,textSelect.length);

          if (electoff.currentFrame == 2)

          {

                    ajWidth(null);

          }

          if (terminalinput.currentFrame == 2)

          {

                    TrWidth(null);

          }

                    focuser();

                    strehrows3();

                    _fontSize();

}