IME library question

wheretheidivides

Active Member
Licensed User
Longtime User
So I have edittext boxes at the bottom of the screen. When I click on them they do not move upwards so the keyboard pops up over top of them. I added the IME library and some code to try to move the screen up above the keyboard. Sometimes this works and sometimes it does not. It seems like if I stay on the page/panel it works, but if I go to another panel it stops working.


I have a panel with 7 editext boxes. This is panel8100. This is set so that it saves the variable from the box and shifts focus to the next box. The last box shifts focus to the first box. This works fine the first time it is run.

B4X:
Sub EditText8101a_EnterPressed
'---------------------------------------------
'Put input into variable.   
   EmployeeID = EditText8101a.Text

'---------------------------------------------
'move to edittext box to next box
   IME.ShowKeyboard(EditText8102a) 'forced deduct hours
   
'---------------------------------------------

End Sub

Sub EditText8102a_EnterPressed
'---------------------------------------------
'Put input into variable.   
   AllDeductMins = EditText8102a.Text

'---------------------------------------------
'move to edittext box to next box
   IME.ShowKeyboard(EditText8102b)
'---------------------------------------------

End Sub
Sub EditText8102b_EnterPressed
'---------------------------------------------
'Put input into variable.   
   TipSharing = EditText8102b.Text

'---------------------------------------------
'move to edittext box to next box
   IME.ShowKeyboard(EditText8102c)
'---------------------------------------------

End Sub

Sub EditText8102c_EnterPressed 
'---------------------------------------------
'Put input into variable.   
   Deduct401k = EditText8102c.Text

'---------------------------------------------
'move to edittext box to next box
   IME.ShowKeyboard(EditText8102d)
   
'---------------------------------------------

End Sub

Sub EditText8102d_EnterPressed 
'---------------------------------------------
'Put input into variable.   
   Matched401k = EditText8102d.Text

   IME.ShowKeyboard(EditText8101b)
      
'---------------------------------------------

End Sub

Sub EditText8150a_EnterPressed 
'---------------------------------------------
'Put input into variable.   
   AllTaxRate = EditText8151c.Text

End Sub

So I run the program the first time and it works fine. The keyboard pops up and the screen moves up. I can see the textbox move from the bottom of the screen up so it is not hidden underneath the keyboard.

Now, when I go to another page/panel and come back, it will not work (this is panel8100 and I click the button to go to panel8150). The keyboard stays on top of the edittext box. So there is something in the following code that is making it do this. I am including the code. Basically, if a person clicks on goto page 2(panel8150), then everything is saved and a new panel pops up. (If I exit the program and restart it, then it works fine again when I go to that page/panel).

B4X:
Sub Globals   
   Dim IME As IME

Sub Activity_Create(FirstTime As Boolean)
   IME.Initialize("IME")

So that is the code I put in and here is my code. This is a subroutine turning off all panels except for the next panel #8150. I do this to make sure the other panels are off and the buttons don't interfeare.

B4X:
         Panel1100.Visible=False
         Panel1200.Visible=False
         Panel1300.Visible=False
         Panel1400.Visible=False
         Panel1500.Visible=False
         Panel1550.Visible=False
         Panel1600.Visible=False
         Panel1650.Visible=False
         Panel1700.Visible=False
         Panel1800.Visible=False
         Panel8100.Visible=False 
         Panel8150.Visible=True ' true
         Panel8200.Visible=False
         Panel8300.Visible=False
         Panel8400.Visible=False
         Panel8500.Visible=False

Now I save all of the variables

B4X:
'---------------------------------------------
'Settings 1 (8100)
   'employee ID number
      EmployeeID=EditText8101a.text
   'What casino is it
      LocationCasino=EditText8101b.text
   'What city is it
      City=EditText8101c.text
   '---------------------------------------------
   'deducted mins
      AllDeductMins=EditText8102a.text
   'tip sharing   
      TipSharing = EditText8102b.text
   '401 deducted pre tax
      Deduct401k = EditText8102c.text
   '401k matched
      Matched401k = EditText8102d.text
      
   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8102a.Text = "" OR EditText8102a.Text =" " Then
         EditText8102a.Text = "0"
         AllDeductMins = EditText8102a.Text
      End If
   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8102b.Text = "" OR EditText8102b.Text = " " Then
         EditText8102b.Text = "0"
         TipSharing = EditText8102b.Text
      End If

   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8102c.Text = "" OR EditText8102c.Text = " " Then
         EditText8102c.Text = "0"
         Deduct401k = EditText8102c.Text
      End If
   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8102d.Text = "" OR EditText8102d.Text = " " Then
         EditText8102d.Text = "0"
         Matched401k = EditText8102d.Text
      End If
      
   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8151c.Text = "" OR EditText8151c.Text = " " Then
         EditText8151c.Text = "0"
         AllTaxRate = EditText8151c.Text
      End If


'---------------------------------------------
'Settings 2 (8150)
   'Tax Rate
      AllTaxRate=EditText8151c.text
      
   'casino hr pay frequency
      CasinoHrPayFreqDaily=Radio8152a.checked
      CasinoHrPayFreqWeekly=Radio8152b.checked
      CasinoHrPayFreqBiWeekly=Radio8152c.checked

   'last day pay week
      LastDayPayWeekMon=Radio8153a.Checked
      LastDayPayWeekTues=Radio8153b.Checked
      LastDayPayWeekWed=Radio8153c.Checked
      LastDayPayWeekThur=Radio8153d.Checked
      LastDayPayWeekFri=Radio8153e.Checked
      LastDayPayWeekSat=Radio8153f.Checked
      LastDayPayWeekSun=Radio8153g.Checked
   
'---------------------------------------------
'Settings 3 (8200)
   'rate for cash hour by casino
      CashHourRate=EditText8201a.text
   '---------------------------------------------
   'casino hr pay frequency
      CashHrPayFreqDaily=Radio8202a.checked
      CashHrPayFreqWeekly=Radio8202b.checked
      CashHrPayFreqBiWeekly=Radio8202c.checked

   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8201a.Text = "" OR EditText8201a.Text =" " Then
         EditText8201a.Text = "0"
         CashHourRate = EditText8201a.Text
      End If
   
'---------------------------------------------
'Settings 4 (8300)

   'tournament casino rate
      TournHourRate=EditText8301a.text
      
   'Tourn hr pay frequency
      TournHrPayFreqDaily=Radio8302a.checked
      TournHrPayFreqWeekly=Radio8302b.checked
      TournHrPayFreqBiWeekly=Radio8302c.checked

   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8301a.Text = "" OR EditText8301a.Text =" " Then
         EditText8301a.Text = "0"
         TournHourRate = EditText8301a.Text
      End If
      
'---------------------------------------------
'Settings 5 (8400)
   'supervisor casino hourly rate
      SuperHourRate=EditText8401a.text
      
   'Super pay frequency
      SuperHrPayFreqDaily=Radio8402a.checked
      SuperHrPayFreqWeekly=Radio8402b.checked
      SuperHrPayFreqBiWeekly=Radio8402c.checked

   '---------------------------------------------
   'do not leave input blank, make 0
      If EditText8401a.Text = "" OR EditText8401a.Text =" " Then
         EditText8401a.Text = "0"
         SuperHourRate = EditText8401a.Text
      End If
      
'---------------------------------------------
'Settings 6 (8500) Sit and Go
   If EditText8511.Text = "" OR EditText8511.Text=" " Then
      EditText8511.Text = "0"
      SitGoHourRate=EditText8511.Text
   End If 

   If EditText8521.Text = "" OR EditText8521.Text=" " Then
      EditText8521.Text = "0"
      SitGoSmallBonusAmount=EditText8521.Text
   End If 

   If EditText8522.Text = "" OR EditText8522.Text=" " Then
      EditText8522.Text = "0"
      SitGoMidBonusAmount=EditText8522.Text
   End If

   If EditText8523.Text = "" OR EditText8523.Text=" " Then
      EditText8523.Text = "0"
      SitGoHighBonusAmount=EditText8523.Text
   End If 

   '---------------------------------------------
   SitGoHourRate=EditText8511.Text
   SitGoSmallBonusAmount=EditText8521.Text
   SitGoMidBonusAmount=EditText8522.Text
   SitGoHighBonusAmount=EditText8523.Text
   
   'Sit and Go hr pay frequency
   SitGoHrPayFreqDaily=Radio8302a.checked
   SitGoHrPayFreqWeekly=Radio8302b.checked
   SitGoHrPayFreqBiWeekly=Radio8302c.checked
   
'---------------------------------------------

and finally I save to sd card
B4X:
Sub INIsaveSettings
'---------------------------------------------
'Saves varibles to SD card
   Select LocationChoose
      Case "1"
         INIsaveSettings1 'SUBROUTINE
      Case "2"
         INIsaveSettings2 'SUBROUTINE
      Case "3"
         INIsaveSettings3 'SUBROUTINE
      Case "4"
         INIsaveSettings4 'SUBROUTINE
      Case "5"
         INIsaveSettings5 'SUBROUTINE
      Case "6"
         INIsaveSettings6 'SUBROUTINE
      Case "7"
         INIsaveSettings7 'SUBROUTINE
   End Select
   
'---------------------------------------------

Sub INIsaveSettings1
'-------------------------------------
'Save stats to text file on SD card
   Dim List1 As List
   
    List1.Initialize
      '-------------------------------------
      'put variables into list
         List1.Add(EmployeeID) '0'ID 1
         List1.Add(LocationCasino) '1'Location 1
         List1.Add(City) '2'City 1
         
         List1.Add(AllDeductMins) '3'All Forced Deducted Mins each day
         List1.Add(AllTaxRate) '4'Guesstimate Tax Rate
         List1.Add(TipSharing) '5 deducted % for brushes
         
         List1.Add(CasinoHrPayFreqDaily) '6'Casino hourly pay rate-daily
         List1.Add(CasinoHrPayFreqWeekly) '7'Casino hourly pay rate-weekly
         List1.Add(CasinoHrPayFreqBiWeekly) '8'Casino hourly pay rate-every 2 weeks
         
         List1.Add(LastDayPayWeekMon) '9'mon
         List1.Add(LastDayPayWeekTues) '10'tues
         List1.Add(LastDayPayWeekWed) '11'wed
         List1.Add(LastDayPayWeekThur) '12'thurs
         List1.Add(LastDayPayWeekFri) '13'fri
         List1.Add(LastDayPayWeekSat) '14'sat
         List1.Add(LastDayPayWeekSun) '15'sun
         
         List1.Add(CashHourRate) '16'Cash Hourly pay rate
         
         List1.Add(CashHrPayFreqDaily) '17'Cash pay rate-daily
         List1.Add(CashHrPayFreqWeekly) '18'Cash pay rate-weekly
         List1.Add(CashHrPayFreqBiWeekly) '19'Cash rate-every 2 weeks
         
         List1.Add(TournHourRate) '20'Tournament Hourly pay rate
         
         List1.Add(TournHrPayFreqDaily) '21'Tournament pay rate-daily
         List1.Add(TournHrPayFreqWeekly) '22'Tournament pay rate-weekly
         List1.Add(TournHrPayFreqBiWeekly) '23'Tournament rate-every 2 weeks
         
         List1.Add(SuperHourRate) '24'Super Hourly pay rate
         
         List1.Add(SuperHrPayFreqDaily) '25'Super pay rate-daily
         List1.Add(SuperHrPayFreqWeekly) '26'Super pay rate-weekly
         List1.Add(SuperHrPayFreqBiWeekly) '27'Super rate-every 2 weeks
         
         List1.Add(Deduct401k) '28 deducted 701k pre-tax
         List1.Add(Matched401k) '29 matched company 401k
         
         List1.Add(StartTime1) '30 start time top of hour
         List1.Add(StartTime2) '31 start time bottom of hour
   
         List1.Add(SitGoHourRate) '32 Sit Go Hourly Pay rate
         List1.Add(SitGoSmallBonusAmount) '33 Sit Go Bonus Amount-Small
         List1.Add(SitGoMidBonusAmount) '34 Sit Go Bonus Amount-Mid
         List1.Add(SitGoHighBonusAmount) '35 Sit Go Bonus Amount-High
         List1.Add(SitGoHrPayFreqDaily) '36 SitGo pay rate-daily
         List1.Add(SitGoHrPayFreqWeekly) '37 SitGo pay rate-weekly
         List1.Add(SitGoHrPayFreqBiWeekly) '38 SitGo pay rate-every 2 weeks
   
    File.WriteList (File.DirRootExternal & "/SavedGame", "PokerTracker_Settings1.txt", List1)
'-------------------------------------

End Sub
End Sub

and I change time for display (basically for the poker dealer to see a start time)

B4X:
Sub TimeTopBottom
'---------------------------------------------
'If nothing in starttimes then default them to :00 and :30

   If StartTime1 = "" Then
      StartTime1 = "00"
   End If
   
   If StartTime2 = "" Then
      StartTime2 = "30"
   End If
   
'---------------------------------------------
'top of the hour
   CheckBox1200am.Text = "12:" & StartTime1 & "AM"
   CheckBox0100am.Text = "01:" & StartTime1 & "AM"
   CheckBox0200am.Text = "02:" & StartTime1 & "AM"
   CheckBox0300am.Text = "03:" & StartTime1 & "AM"
   CheckBox0400am.Text = "04:" & StartTime1 & "AM"
   CheckBox0500am.Text = "05:" & StartTime1 & "AM"
   
   CheckBox0600am.Text = "06:" & StartTime1 & "AM"
   CheckBox0700am.Text = "07:" & StartTime1 & "AM"
   CheckBox0800am.Text = "08:" & StartTime1 & "AM"
   CheckBox0900am.Text = "09:" & StartTime1 & "AM"
   CheckBox1000am.Text = "10:" & StartTime1 & "AM"
   CheckBox1100am.Text = "11:" & StartTime1 & "AM"
   '----------------------------------------
   CheckBox1200pm.Text = "12:" & StartTime1 & "PM"
   CheckBox0100pm.Text = "01:" & StartTime1 & "PM"
   CheckBox0200pm.Text = "02:" & StartTime1 & "PM"
   CheckBox0300pm.Text = "03:" & StartTime1 & "PM"
   CheckBox0400pm.Text = "04:" & StartTime1 & "PM"
   CheckBox0500pm.Text = "05:" & StartTime1 & "PM"
   
   CheckBox0600pm.Text = "06:" & StartTime1 & "PM"
   CheckBox0700pm.Text = "07:" & StartTime1 & "PM"
   CheckBox0800pm.Text = "08:" & StartTime1 & "PM"
   CheckBox0900pm.Text = "09:" & StartTime1 & "PM"
   CheckBox1000pm.Text = "10:" & StartTime1 & "PM"
   CheckBox1100pm.Text = "11:" & StartTime1 & "PM"

'---------------------------------------------
'Bottom of the hour
   CheckBox1230am.Text = "12:" & StartTime2 & "AM"
   CheckBox0130am.Text = "01:" & StartTime2 & "AM"
   CheckBox0230am.Text = "02:" & StartTime2 & "AM"
   CheckBox0330am.Text = "03:" & StartTime2 & "AM"
   CheckBox0430am.Text = "04:" & StartTime2 & "AM"
   CheckBox0530am.Text = "05:" & StartTime2 & "AM"
   
   CheckBox0630am.Text = "06:" & StartTime2 & "AM"
   CheckBox0730am.Text = "07:" & StartTime2 & "AM"
   CheckBox0830am.Text = "08:" & StartTime2 & "AM"
   CheckBox0930am.Text = "09:" & StartTime2 & "AM"
   CheckBox1030am.Text = "10:" & StartTime2 & "AM"
   CheckBox1130am.Text = "11:" & StartTime2 & "AM"
   '----------------------------------------
   CheckBox1230pm.Text = "12:" & StartTime2 & "PM"
   CheckBox0130pm.Text = "01:" & StartTime2 & "PM"
   CheckBox0230pm.Text = "02:" & StartTime2 & "PM"
   CheckBox0330pm.Text = "03:" & StartTime2 & "PM"
   CheckBox0430pm.Text = "04:" & StartTime2 & "PM"
   CheckBox0530pm.Text = "05:" & StartTime2 & "PM"
   
   CheckBox0630pm.Text = "06:" & StartTime2 & "PM"
   CheckBox0730pm.Text = "07:" & StartTime2 & "PM"
   CheckBox0830pm.Text = "08:" & StartTime2 & "PM"
   CheckBox0930pm.Text = "09:" & StartTime2 & "PM"
   CheckBox1030pm.Text = "10:" & StartTime2 & "PM"
   CheckBox1130pm.Text = "11:" & StartTime2 & "PM"
'---------------------------------------------

End Sub

I hope this is not too much code, but I thought I'd though it all in there just in case. Any ideas of what makes the soft keyboard not appear? It works fine the first time, but after going to a new page/panel, it stops working.
 
Last edited:

wheretheidivides

Active Member
Licensed User
Longtime User
well that link is where I got what I got so far.

I don't understand why I need to change the button height. I just want to move the keyboard up.
B4X:
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
   btnHideKeyboard.Top = NewHeight - btnHideKeyboard.Height
   EditText1.Height = btnHideKeyboard.Top - EditText1.Top
End Sub

thanks for the info, but I have no idea what you mean. It also doesn't explain why sometimes it works and sometimes it doesn't.
 
Upvote 0

KZero

Active Member
Licensed User
Longtime User
So I have edittext boxes at the bottom of the screen. When I click on them they do not move upwards so the keyboard pops up over top of them. I added the IME library and some code to try to move the screen up above the keyboard. Sometimes this works and sometimes it does not. It seems like if I stay on the page/panel it works, but if I go to another panel it stops working.
as what i understand of your question you don't need to change the height you need to change the edittext TOP
and you may will need to change other objects height to arrange them with the new height after the keyboard apper


It also doesn't explain why sometimes it works and sometimes it doesn't.

check your Manifest file (From Project Menu Select Manifest Editor)
remove android:windowSoftInputMode="stateHidden|adjustPan" if found
and use only IME


B4X:
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
    YOURTEXTBOX.Top = NewHeight - YOURTEXTBOX.Height
End Sub
 
Last edited:
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
Mybe it's how I am doing this.

B4X:
Sub EditText1702a_EnterPressed
'---------------------------------------------
'Put input into variable.   
   CashTips = EditText1702a.Text

'---------------------------------------------
'move to edittext box to next box
   IME.ShowKeyboard(EditText1702b)
   
'---------------------------------------------

End Sub

What I want is when the user presses the edittext box for the keyboard to come up and the screen to adjust so you can see the editext box.

Here I am using the EnterPressed command. This is when the user presses the done or next on the keyboard. Is there some command when the user presses the editext box?
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
I found this somewhere. This added to the manifest seems to work. I tested it a few times and it seems OK. If I have any further problems I'll send a mew message here

B4X:
SetActivityAttribute(Main, android:windowSoftInputMode, "stateHidden|adjustPan")
 
Upvote 0
Top