Your code will fail if m.searchBtn is out of scope or is being seen as the wrong type.
You can test this by placing a STOP after print "KEYBOARD FOCUS: "; m.miniKeyboard.hasFocus() and then do a print m.searchBtn in the debugger to see what it thinks it is.
What you're trying to do does work if the search button is appended as a child to the minikeyboard - it makes it a bit simpler at least in my experience, besides, you probably want to reset the position to "a" each time the search window is initiated instead of keeping the selection on the last item highlighted - consider that a bug with the keyboards that they need to be destroyed and recreated to fix that issue.
search screen xml
<component name="SearchScreen" extends="Group">
<children>
<Rectangle/>
<Button id="Search"/>
<MiniKeyboard id="MK"/>
</children>
</component>
xml addition for minikeyboard to screen you want to add it to
<!-- Search screen -->
<SearchScreen
id="MK"
visible="FALSE"/>
Init brs for the screen you want to add it to
m.SearchScreen=m.top.findNode("MK")
OnItemSelected brs
'Destroy and Recreate Search Screen to reset focus to "a"
m.searchscreen.removeChildIndex(2) 'destroy minikeyboard
m.searchscreen.removeChildIndex(1) 'destroy button
m.searchscreen.removeChildIndex(0) 'destroy rectangle
m.searchscreen.createChild("Rectangle")
m.searchscreen.createChild("Button")
m.searchscreen.createChild("MiniKeyboard")
m.r1=m.searchscreen.getChild(0)
m.r1.width=558'228
m.r1.height=759'76
m.r1.color="0x0F0F0FFF"
m.r1.translation=[14,0]
m.b1=m.searchscreen.getChild(1)
m.b1.id="search"
m.b1.text="Search"
m.b1.showFocusFootprint=FALSE
m.b1.minWidth=240
m.b1.maxWidth=1000
m.b1.translation=[164,670]
m.b1.observeField("buttonSelected","SearchActivated")
m.searchscreen.translation=[668,170]
If m.devicemodel="4200X"
m.SearchScreen.GetChild(2).keyboardBitmapUri="pkg:/images/search.png"
Else
m.SearchScreen.GetChild(2).keyboardBitmapUri="pkg:/images/searchfhd.png"
End If
m.searchscreen.GetChild(2).texteditbox.maxTextLength=20
m.searchscreen.GetChild(2).texteditbox.backgroundUri="pkg:/images/searchtext.png"
m.searchscreen.getchild(2).text=""
m.searchscreen.visible=TRUE
OnKeyEvent brs
If m.searchscreen.visible=TRUE 'Handle search screen keys
If key="up"
If m.searchscreen.getchild(1).hasFocus()
m.searchscreen.getchild(2).SetFocus(TRUE)
End If
Else If key="down"
If Not m.searchscreen.getchild(1).hasFocus()
m.searchscreen.getchild(1).SetFocus(TRUE)
End If
End If
End If
SearchActivated callback - for when the button is selected from the search screen
Function SearchActivated()
temp=m.searchscreen.getchild(2).Text
m.SearchScreen.visible=FALSE ' make search screen disappear from display
'do what you want to do with the search term and display results or no results
'remember to setfocus the new screen with the results or no results
End Function