Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gaurachit
Channel Surfer

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 9
belltown
Roku Guru

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.
0 Kudos
RokuMarkn
Visitor

Re: roImageCanvas event handling

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

--Mark
0 Kudos
TheEndless
Channel Surfer

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
Channel Surfer

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
Channel Surfer

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
Channel Surfer

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
Visitor

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
Channel Surfer

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
Channel Surfer

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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.