Android Question How stop keyboard showing when clicking clickable csbuilder text?

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Have a EditText called edtSQL with clickable csbuilder text with the eventname "Table":

B4X:
cs.Underline.Bold.Color(SQLColours(10)).Clickable("Table", _
arrSQLWords(i).strWord).Append(arrSQLWords(i).strWord).Pop.Pop.Pop.Pop

B4X:
Sub Table_Click(Tag As Object)
 Dim strTable As String
 HideKeyboard
 strTable = CStr(Tag)
  Dim rs As ResumableSub = Dialog.Show(Activity, Array As Object("Count rows", "Show fields", "Cancel"), _
          "Info for the table " & strTable, "", "", _
          -1, False, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Null, False, arrS)
 Wait For (rs) Complete (strResult As String)
  Select Case strResult
  Case "Count rows"
   CountTableRows(strTable, True)
  Case "Show fields"
   ShowFields(strTable, True)
  Case "Cancel"
   Return
 End Select
End Sub

The edtSQL_Click event will be fired before Table_Click, triggering the keyboard popping up.
I can hide the keyboard, but my Table_Click event will show a dialog so this will be pushed up then go down again. How can I avoid this?

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
You can change the adjust mode to adjustResize. This will prevent the activity from being pushed. See the IME tutorial.

That is what have. In the manifest:

B4X:
SetActivityAttribute(Main, android:windowSoftInputMode, adjustResize)

This is my IME_HeightChanged event:

B4X:
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
 
 Dim bEdtSQLHeightChanged As Boolean
 Dim iKeyBoardHeight As Int
 Dim iOldEdtSQLHeight As Int
 Dim iNewEdtSQLHeight As Int
 
 bKeyboardVisible = NewHeight < OldHeight

 If Dialog.IsVisible Then
  Dialog.Resize(100%x, NewHeight)
  Return
 End If
  
 If General.iCurrentPanelType = 6 Then
  If bKeyboardVisible Then
   'only decrease height of edtSQL if keyboard was encroaching on it
   '----------------------------------------------------------------
   If edtSQL.Top + edtSQL.Height > NewHeight Then
    iOldEdtSQLHeight = edtSQL.Height
    iKeyBoardHeight = OldHeight - NewHeight
    edtSQL.Height = (pnlSQLEditor.Height - iKeyBoardHeight) - edtSQL.top
    bEdtSQLHeightChanged = True
    iNewEdtSQLHeight = edtSQL.Height
    iSQLEditDecreased = iOldEdtSQLHeight - iNewEdtSQLHeight
   End If
  Else
   'no need to increase height of edtSQL if it is large enough
   '----------------------------------------------------------
   If iSQLEditTextHeight + edtSQL.Padding(1) + edtSQL.Padding(3) + 10dip > edtSQL.Height Then
    edtSQL.Height = edtSQL.Height + iSQLEditDecreased
    bEdtSQLHeightChanged = True
     End If
  End If
  
  If bEdtSQLHeightChanged = False Then
   Return
  End If
  
  If lblSQLResult.Visible = True Then
   lblSQLResult.Top = edtSQL.Top + edtSQL.Height
   End If
  
  If tblSQLResult.Size > 0 Then
   tblSQLResult.Top = lblSQLResult.Top + lblSQLResult.Height
  End If
  
 End If
 
End Sub


RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
That is what have. In the manifest:

B4X:
SetActivityAttribute(Main, android:windowSoftInputMode, adjustResize)

This is my IME_HeightChanged event:

B4X:
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
 
 Dim bEdtSQLHeightChanged As Boolean
 Dim iKeyBoardHeight As Int
 Dim iOldEdtSQLHeight As Int
 Dim iNewEdtSQLHeight As Int
 
 bKeyboardVisible = NewHeight < OldHeight

 If Dialog.IsVisible Then
  Dialog.Resize(100%x, NewHeight)
  Return
 End If
 
 If General.iCurrentPanelType = 6 Then
  If bKeyboardVisible Then
   'only decrease height of edtSQL if keyboard was encroaching on it
   '----------------------------------------------------------------
   If edtSQL.Top + edtSQL.Height > NewHeight Then
    iOldEdtSQLHeight = edtSQL.Height
    iKeyBoardHeight = OldHeight - NewHeight
    edtSQL.Height = (pnlSQLEditor.Height - iKeyBoardHeight) - edtSQL.top
    bEdtSQLHeightChanged = True
    iNewEdtSQLHeight = edtSQL.Height
    iSQLEditDecreased = iOldEdtSQLHeight - iNewEdtSQLHeight
   End If
  Else
   'no need to increase height of edtSQL if it is large enough
   '----------------------------------------------------------
   If iSQLEditTextHeight + edtSQL.Padding(1) + edtSQL.Padding(3) + 10dip > edtSQL.Height Then
    edtSQL.Height = edtSQL.Height + iSQLEditDecreased
    bEdtSQLHeightChanged = True
     End If
  End If
 
  If bEdtSQLHeightChanged = False Then
   Return
  End If
 
  If lblSQLResult.Visible = True Then
   lblSQLResult.Top = edtSQL.Top + edtSQL.Height
   End If
 
  If tblSQLResult.Size > 0 Then
   tblSQLResult.Top = lblSQLResult.Top + lblSQLResult.Height
  End If
 
 End If
 
End Sub


RBS


I think I have fixed this now by altering this in the above code:

B4X:
 If Dialog.IsVisible Then
  Dialog.Resize(100%x, NewHeight)
End If

To this:

B4X:
If General.iCurrentPanelType <> 6 Then
  If Dialog.IsVisible Then
   Dialog.Resize(100%x, NewHeight)
   Return
  End If
End If


RBS
 
Upvote 0
Top