Backspace key on Android not working...

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Backspace key on Android not working...

Post by sphere » Fri Oct 23, 2015 9:04 am

Hello,

i have a problem that the Backspacekey is not working on Android (tested on phone and tablet), but it works on the Android Emulator.
Of course it could be my mistake (that's probably it but....)

Any help will be great on this :)
It's just 2 entry field with only one line of text. One for the URL and one for a max 2 digits entry. A mistake is easily made so it would be great if backspace works.
I added a code that would erase the whole line(it's not working) but just erasing one character at a time would also be benificial.

This is the card script:

Code: Select all

global gIP
global gNr
on preOpenCard
   set the acceleratedrendering of this stack to false
      set the vScroll of field"address" of card 3 to 0
   set the vScroll of field"dispnr" of card 3 to 0
end preOpenCard

on openCard
   mobileControlCreate "input", "myIPAddress"
   mobileSetKeyboardType "alphabet"
  mobileControlSet "myIPAddress", "visible", true
  mobileControlSet "myIPAddress", "rect", "50,500,250,100"
  mobileControlSet "textColor", "black"
  mobileControlSet "•	backgroundColor", "white"
  put mobilecontrolget("input","myIPAddress") into gIP
  end openCard

on closeCard
   set the acceleratedrendering of this stack to true
end closeCard
and this is the URL field script:

Code: Select all

global gIP
#set the acceleratedrendering of this stack to false
mobileControlCreate "multiline", "myTextInput"
mobileSetKeyboardType "alphabet"

on backspaceKey
   put empty into me
   end backspaceKey

on returnInField
      if field "address" is empty then answer "Fill in server address first." & cr & "Begin with http:// and do NOT use / at the end" with "Ok"
   else  if field "address"contains "http://" then
      put field "address" into URL ( "file:" & specialFolderPath("Documents")  & "/showitIP.txt" )
      put field "address" into gIP
      answer "Thank you. The server address you entered is set." with "Ok"
      focus on nothing
      #set the acceleratedrendering of this stack to true
      go to card 1
   else answer "Only server addresses starting with http:// are allowed." with "Ok"
        #send "mouseUp" to button"set" of card 2
	end returnInField

and this is the digit input field:

Code: Select all

global gNr
#set the acceleratedrendering of me to false
mobileControlCreate "multiline", "myTextInput"
mobileSetKeyboardType "numeric"
on backspaceKey
   put empty into me
end backspaceKey

on keyDown pKey
   #if pKey is a number then
    if the length of me >= 2 then
        // If there are 2 or more characters in the field
        // beep and prevent text entry
        //beep
    else
        // Allow text entry by passing the keyDown message
        pass keyDown
     end if
     #end if
end keyDown

on returnInField
      if field "dispnr" is empty then answer "Fill in display number first."  with "Ok"
      else  
         put field "dispnr" into gNr
     send mouseUp to button "Setdispnr"
      focus on nothing
      #set the acceleratedrendering of me to true
      
           end if
	
end returnInField

Thanks for any help :D

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Backspace key on Android not working...

Post by Klaus » Fri Oct 23, 2015 12:43 pm

Hi sphere,

sorry, no idea about Android, but there is a general problem:
...
mobileControlCreate "multiline", "myTextInput"
mobileSetKeyboardType "alphabet"
...
These commands need to be wrapped inside of a handler (e.g. pre-/opencard)
or they will not get "triggered" and of course not being executed (read: not works!)!


Best

Klaus

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Backspace key on Android not working...

Post by sphere » Fri Oct 23, 2015 6:16 pm

Hi Klaus,

ok thanks for your suggestion.
I will look into it.

Kind regards,
Sphere

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Backspace key on Android not working...

Post by sphere » Sat Oct 24, 2015 9:37 pm

In android you need to use Alpha 0-255 instead op opaque to get rid of the ugly overlay.
Then the characters were shifted upwards for the half of it.
Changing the size etc did not help much.

a lot of hasle for a simple text input.
(i still don't understand why the backspace button is not working on a simple input field)
With the mobilecontrolcreate the backspace works but....all that hasle....

So i used a simpler solution were the backspace button works ok.
And that is to use the ASK command.
Then i copy the inserted text to the former input field and all is well!

Much easier. :)

Sphere

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Backspace key on Android not working...

Post by jacque » Sun Oct 25, 2015 5:42 pm

Your handler puts empty into the LC field ("me") but the user is typing into the native field. They are two different things. If you want the native field to update after a backspace you need to set its text to the new value using mobileControlSet.

But you shouldn't need to handle backspace at all if you only want single character deletions, Android handles that automatically.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sphere
Posts: 1145
Joined: Sat Sep 27, 2014 10:32 am

Re: Backspace key on Android not working...

Post by sphere » Sun Oct 25, 2015 9:16 pm

Yes you are completely right :)

But...i also tried it with # before every line of that backspace part
Also then it won't delete the last character, that is when only using a field as an input. (don't know if that is a bug, have to test it with an other test stack)

I see now, after playing some more with it that i do 2 things mixed up a mobilecontrol and a field.
So in an other test i set the field so that you can't type in it and then the mobilecontrol that it is total transparent, it then looks like if your typing into the field itself.
Other fault is i set it to multiline, instead it should be a single line.

All mobilecontrol are now in the card script only, and also deleted when card is closed, becasue else it won't go away and you see it on other cards too.

In the mean time i use the solution with the ask function which is working good now.
and i'll keep testing with the mobilecontrol function until i get it working good :mrgreen:

Post Reply