Bug? IME Fail to handle open keyboard event

hookshy

Well-Known Member
Licensed User
Longtime User
- Summary: Pressing the edittext to fill the required text fails to open keyboard
- Actual Behavior: When focus changes on other object (button pressed) the keyboard will not open
when pressing the edittext

- Expected Behavior: Keyboard must open when pressing edittext
-SOLUTION : A PAIR OF GLASES FOR MOTOROLA ROM

-I do not use ime library but the core version 2.47
Tested on motorola defy+ ,motorola motolux, vodafone smart 2 , All android 2.3...

-Additional resources
here is a film that I have made to demonstrate the issue !!
https://www.dropbox.com/s/m3o1c9hdty8agxc/motorola test.3gp

here is my test project:

https://www.dropbox.com/s/osns2fczkte5p9x/ime.rar

Reproduction Steps
i PRESS ADD PRODUCT BUTTON
i FILL IN TEXT SAMPLE ...TEST
HIT SAVE AND EXIT
PRESS BACK KEY TO CLOSE KEYBORD
PRESS BACKKEY TO HIDE PANEL
i PRESS ADD PRODUCT AGAIN AND THE KEYBOARD WILL NOT OPEN ANYMORE !!

***********
I tryed to use ime library and using ime1.hidekeyboard but it does not solve the problem

here is the same code from the test project !
B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim Button1 As Button
    Dim Panel1 As Panel
    Dim lv1 As ListView
    Dim Button2 As Button
    Dim EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
  
    lv1.Width=Activity.Width
    lv1.Height=Activity.Height-Button1.Height
    lv1.Top=Button1.Height
  
    Panel1.Width=Activity.Width
    Panel1.Left=Activity.Width
  
    EditText1.Color=Colors.White
    EditText1.TextColor=Colors.Black
    EditText1.Hint="enter text here"
  
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean



If KeyCode = KeyCodes.KEYCODE_BACK Then

If Panel1.Left=0 Then
Panel1.Left=Activity.Width
Else
Activity.Finish
End If



Return True  
Else

End If

End Sub


Sub Button1_Click
Panel1.Left=0
Panel1.BringToFront
  
End Sub
Sub Button2_Click
    Panel1.Left=Activity.Width
    lv1.AddSingleLine(EditText1.Text)
End Sub
 
Last edited:

hookshy

Well-Known Member
Licensed User
Longtime User
I have unfinished business with edittext !!

I am learning all the time and finding issues that turn out to be our own mistakes ... forgive that I have not approached well the functions of some or the libs related to my questions
It is not so important if IDE do something wrong or Android OS si not handling good the focus on edittext ..problem is that my keyboard is not showing and I want to find out why ...

So.... here are my conclusions and I invite other to test this issue only on Android 2.3...Panel.bringToFront bug
the statement:
B4X:
Panel1.Left=0
Panel1.BringToFront
'this code will bring a panel on front with one edittext and one button 
'edit the field and press save ...the panel hides ... repeat procedure to enter new text ..
is causing all the problems... the edit text is loosing focus and the keyboard is not showing !!!

uselless procedure I have tried :
B4X:
EditText1.RequestFocus
IME1.ShowKeyboard(EditText1)
do events nothing
create button on panel push to request focus again
ime.hidekeyboard is not helping with my problem..is just helping user saving time

Adding edittext1.bringToFront solves the problem
B4X:
[CODE]Panel1.Left=0
Panel1.BringToFront
edittext1.BringToFront
[/CODE]

Generally we need to use the panel.bringToFront option... removing from my code also solved the problem no need to call edittext1.bringToFront
The OS of android 4.0 is handeling very well the press on edittext ...the keyboard works just fine


request focus
tries to put focus into this view
request true if the focus was set (in my case edittext1_FocusChanged (HasFocus As Boolean) returned allwasys false in the presence of bug)

Ime.showkeyboard(view..)
tries to set the focus on edittext
open keyboard if the focus on the view was set (in this case the focus is lost as I am sometimes when my wife is telling me: Are you with me
no I'll be right back I have a bug here :))



Questions :
1.When do you use this option ? Why have been created in first place ?
2.Can someone confirm the issue i have met ?

Thank you!
Hookshy
 

hookshy

Well-Known Member
Licensed User
Longtime User
I am not using any services.. I bring a panel on front that contains edittext in order to imput text and save it to a listivew that is all !
BringToFront method cause the lose of focus on edittext on andorid 2.3..when called twice...(on first start of the activity the keyboard is showing then after the second focus on panel that is coming on front the edittext lose focus and the keyboard is not showing ).

Pressing an edit text should force the OS to open keyboard !! it is not happening on android 2.3 on certain situations ...like calling bringtofront on a panel before focusing on other view like edittext
 

LucaMs

Expert
Licensed User
Longtime User
"Adding edittext1.bringToFront solves the problem", you wrote.

Are you sure that edittext1 parent is the panel and not the activity?

Can you attach a sample project?

[P.S. found in #1]
 
Last edited:

hookshy

Well-Known Member
Licensed User
Longtime User
B4X:
Dim jo As EditText1
jo.RunMethod("bringToFront", null)

I do not find such mettod on edittext , is this code a reflector ...I do not understand the code.

Are you sure that edittext1 parent is the panel and not the activity?
Lucas Ms ... the edittext is defined within a panel wich i bring to front in order to fill the edittext
 

hookshy

Well-Known Member
Licensed User
Longtime User
I have tested your sugestion and the issues is gone with your method !

B4X:
Sub Button1_Click
Panel1.Left=0

'Panel1.BringToFront 'calling this method alone generted the bug
'EditText1.BringToFront (this action solved the problem)
'Statement below works as well

Dim jo As JavaObject = Panel1 '(this statement works al well )
jo.RunMethod("bringToFront", Null)

End Sub
 
Top