Keyboard closing problem

I am creating a POC for simple search functionality in my channel. I am able to Show the search popup as required when I am pressing ok on the input area of search screen it is showing the keyboard screen according to expectation.

But when I am closing the keyboard by pressing Ok or Cancel button the Keyboard screen doesn’t close. I just go at back of the search screen and when I close the search screen it closes the keyboard screen.

To sea the behaviour I have just make 2 more methods for showKeyboard
showKeyboard2() and showKeyboard3()

and I am surprise when I call them in place of showKeyboard() like:
when I call showKeyboard2() method it never shows the keyboard which is absolutely correct behaviour
but when I call showKeyboard3() it opens the keyboard but after 5 seconds it again takes the keyboard in back of the search in place of closing it.

Please have a look of my code I am giving with this post and suggest that what should I do to close the keyboard successfully.

Function Main()
		canvas = CreateObject("roImageCanvas")
		port = CreateObject("roMessagePort")
		canvas.SetMessagePort(port)
		list = []
		list.push({Color:"#FFFFFF", CompossionMode:"Source"})
		list.push({
			Text:"Press OK to show Search Screen", 
			TextAttrs:{color:"#000000", font:"Medium", HAlign:"Left",VAlign:"Top", Direction:"LeftToRight"}, 
			TargetRect:{x:300, y:100, w:500, h:40}
		})
		canvas.SetLayer(0, list)
		canvas.show()
		while true
			msg = wait(0, port)
			if(Type(msg) = "roImageCanvasEvent")
				if(msg.IsremoteKeyPressed())
					index = msg.GetIndex()
					if(index = 6) 'OK key pressed
						showSearchPopupScreen("Title")
					end if
				else if(msg.IsScreenClossed())
					
				end if
			else
				print "Unexpected Event."
			end if
		end while
End Function

function showSearchPopupScreen(searchType as String)
	selectedRow = 0
	REM** Show Lower opacity background screen 
	facadeCanvas = CreateObject("roImageCanvas")
	port = CreateObject("roMessagePort")
	facadeCanvas.SetMessagePort(port)
	facadeCanvas.SetLayer(0, {Color:"#99000000", CompossionMode:"Source_Over"})
	facadeCanvas.show()

	REM ** Show the SearchPopupScreen
	popupCanvas = CreateObject("roImageCanvas")
	popupCanvas.SetMessagePort(port)
	popupCanvas.AllowUpdates(false)
	list = []
	list.push({
			url:"pkg:/images/HD/canvasBack.png", 
			TargetRect:{x:240, y:210, w:700, h:300}
		})
	list.push({
			Text:"Enter " + searchType + " Name:", 
			TextAttrs:{color:"#000000", font:"Medium", HAlign:"Left",VAlign:"Top", Direction:"LeftToRight"}, 
			TargetRect:{x:300, y:250, w:500, h:40}
		})
	list.push({
			url:"pkg:/images/HD/input_text_bg.png", 
			TargetRect:{x:390, y:300, w:400, h:70}
		})
	list.push({
			url:"pkg:/images/HD/ok.png", 
			TargetRect:{x:515, y:400, w:150, h:55}
		})
	popupCanvas.SetLayer(0, list)
	popupCanvas.SetLayer(1, {url:"pkg:/images/HD/input_text_bg_hover.png", TargetRect:{x:390, y:300, w:400, h:70}})
	popupCanvas.AllowUpdates(true)
	popupCanvas.show()
	while true
		msg = wait(0, port)
		if(Type(msg) = "roImageCanvasEvent")
			if(msg.IsremoteKeyPressed())
				index = msg.GetIndex()
				if(index = 0) 'Back key pressed
					return -1
				else if(index = 2) 'Up key pressed
					print "popup canvas Up key pressed."
					if(selectedRow = 1)
						popupCanvas.SetLayer(1, {url:"pkg:/images/HD/input_text_bg_hover.png", TargetRect:{x:390, y:300, w:400, h:70}})
						selectedRow = 0
					end if
				else if(index = 3) 'Down key pressed
					print "popup canvas Up key pressed."
					if(selectedRow = 0)
						popupCanvas.SetLayer(1, {url:"pkg:/images/HD/hover.png", TargetRect:{x:515, y:400, w:150, h:55}})
						selectedRow = 1
					end if
				else if(index = 4) 'Left move
				else if(index = 5) 'Right move
				else if(index = 6)
					print "Selected Row: "selectedRow
					'result = showKeyboard()
					'result = showKeyboard2()
					result = showKeyboard3()
				end if
			else if(msg.IsScreenClosed())
				return -1
			end if
		else
			showPopupScreen()
		end if
	end while
end function

function showKeyboard() as Dynamic
	screen = CreateObject("roKeyboardScreen")
	port = CreateObject("roMessagePort")
	screen.setMessagePort(port)
    screen.SetDisplayText("Enter Director Name")
	screen.setSecureText(false)
    screen.AddButton(1, "Ok")
    screen.AddButton(2, "Cancel")
    screen.Show() 
	result = invalid
    while true
        msg = wait(0, port) 
        if type(msg) = "roKeyboardScreenEvent"
			print  "KeyBoard Event: "
			print Type(msg)
			print msg
            if (msg.isScreenClosed())
				print "Comes into isScreenClosed event of KeyboardScreen.."
				exit while
            else if (msg.isButtonPressed())
                if msg.GetIndex() = 1
					print "Text Entered: " screen.GetText()
					if(screen.GetText().trim() <> "")
						result = screen.GetText()
						exit while
					else
						dialog = CreateObject("roMessageDialog")
						dialog.SetMessagePort(screen.GetMessagePort()) 
						dialog.SetTitle("Alert!!")
						dialog.SetText("Field cannot be empty.")
						dialog.AddButton(1, "Ok")
						dialog.EnableBackButton(true)
						dialog.Show()
					end if
				else if msg.GetIndex() = 2
					exit while
                end if
            end if
		else if type(msg) = "roMessageDialogEvent"
			 if (msg.isButtonPressed())
                if (msg.GetIndex() = 1)
                    dialog.close()
                end if
            else if (msg.isScreenClosed())
                dialog.close()
            end if
		else 
			print "Un-expected event"
		end if
    end while 
	screen.close()
	return result
end function

function showKeyboard2() as Dynamic
	screen = CreateObject("roKeyboardScreen")
	port = CreateObject("roMessagePort")
	screen.setMessagePort(port)
    screen.SetDisplayText("Enter Director Name")
	screen.setSecureText(false)
    screen.AddButton(1, "Ok")
    screen.AddButton(2, "Cancel")
    screen.Show() 
	screen.close()
	return ""
end function

function showKeyboard3() as Dynamic
	screen = CreateObject("roKeyboardScreen")
	port = CreateObject("roMessagePort")
	screen.setMessagePort(port)
    screen.SetDisplayText("Enter Director Name")
	screen.setSecureText(false)
    screen.AddButton(1, "Ok")
    screen.AddButton(2, "Cancel")
    screen.Show() 
	sleep(5000)
	screen.close()
	return ""
end function

Can anyone help me on this issue.

I’ve encountered similar problems when playing around with roImageCanvas components that call standard BRS components. Although the documentation says, “When a screen is closed, it is removed from the stack and the screen which was below the top screen then becomes visible”, the behavior I’ve observed is that the screen isn’t actually removed from the display; it is merely over-written by re-displaying the screen that was below the top screen, which amounts to the same thing if the screen below the top screen has an opaque background, as most do. However, if the screen below the top screen does not have an opaque background then the previous screen will still be visible through the transparent areas of the old top screen.

In your case, your popup canvas does not have an opaque background, or any background layer at all actually, so what you’re seeing is the non-transparent portions of that layer superimposed over the keyboard screen, which is no longer active even though its pixels are still displayed. I think if you give your popup canvas an opaque background layer (although that may not be what you want) then you’ll no longer see the keyboard screen when it is closed.

You have a few typos to fix also: CompossionMode → CompositionMode, and IsScreenClossed → IsScreenClosed

Hi Beltown,

Thanks for reply.
Yes you are right if I give the opaque background layer on popup canvas then It become invisible actually it(keyboard screen) hides behind the popup.
But I need transparent or semi-transparent background for popup menu and in that case the keyboard shows in behind of popup.
Is there any other way you supposed to handle this kind of situation.

Also thanks to make my attention on the typos.