Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
gaurachit
Level 7

roImageCanvas event handling

Hi,

I want to handle the situation where roImageCanvasEvent is making a stack.

Consider the scenario:
app is fetching the data from web-service, at the same time if I press the remote keys continuously then all the roImageCanvasEvent are accumulate and make a stack and execute after the web-service response received.

I need to ignore the roImageCanvasEvent when I am trying to get the data from service or any other situation like this.

Is any built in property available to handle this or any workaround ? Please let me know.

Thanks
0 Kudos
9 Replies
belltown
Level 7

Re: roImageCanvas event handling

Fetch the data from your web service asynchronously, so while you're waiting for the transfer to complete you can also be handling (and ignoring if you wish) the key presses on your image canvas.
https://github.com/belltown/
0 Kudos
RokuMarkn
Level 7

Re: roImageCanvas event handling

You could also use separate message ports for the image canvas and the transfer.

--Mark
0 Kudos
TheEndless
Level 7

Re: roImageCanvas event handling

You could also spin through all of the queued events when your web service request returns, and ignore all but the last one.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
gaurachit
Level 7

Re: roImageCanvas event handling

"TheEndless" wrote:
You could also spin through all of the queued events when your web service request returns, and ignore all but the last one.


Hi TheEndless,

From where I will get the list of queued events and how can I ignore them?
0 Kudos
gaurachit
Level 7

Re: roImageCanvas event handling

"RokuMarkn" wrote:
You could also use separate message ports for the image canvas and the transfer.

--Mark



Hi RokuMarkn,

I am using the separate ports for ImageCanvas and urlTransfer but not able to handle this is there any trick to handle this kind of situation.
Actually I have separate method here for urltransfer where I am using a new port different from the ImageCanvas port.

Thanks
0 Kudos
TheEndless
Level 7

Re: roImageCanvas event handling

"gaurachit" wrote:
"TheEndless" wrote:
You could also spin through all of the queued events when your web service request returns, and ignore all but the last one.


Hi TheEndless,

From where I will get the list of queued events and how can I ignore them?

roMessagePort.PeekMessage() and roMessagePort.GetMessage()

Something along these lines might work:
msg = invalid
While Type(canvas.GetMessagePort().PeekMessage()) = "roImageCanvasEvent"
msg = canvas.GetMessagePort().GetMessage()
End While
Return msg

Assuming your canvas has it's own port, this would dequeue and discard all but the last roImageCanvasEvent. You can/should refine it to deal with any events you don't want to ignore (e.g., isScreenClosed()).
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
RokuMarkn
Level 7

Re: roImageCanvas event handling

Hm, although it wasn't phrased very clearly, I thought the OP's request was to queue the ImageCanvas events for later processing, not to discard them.

--Mark
0 Kudos
TheEndless
Level 7

Re: roImageCanvas event handling

"RokuMarkn" wrote:
Hm, although it wasn't phrased very clearly, I thought the OP's request was to queue the ImageCanvas events for later processing, not to discard them.

--Mark

No, he said the problem is that they queue up while the message loop is blocked during the web service request and processing. The end result is that he gets a flood of isRemoteKeyPressed() events after the web service request completes. At least that's how I read it.

Another solution would be to put up a wait dialog or another image canvas with a wait message in front of the canvas in question, so the keypresses are intercepted by that dialog/screen, and never make it to the original canvas.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
gaurachit
Level 7

Re: roImageCanvas event handling

Hi All Thanks for response,

I am able to solve this situation by adding one more transparent canvas over the main canvas which handles the unwanted events.

Thanks for support.
0 Kudos