Forum Discussion

gaurachit's avatar
gaurachit
Channel Surfer
11 years ago

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

9 Replies

  • 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.
  • You could also use separate message ports for the image canvas and the transfer.

    --Mark
  • You could also spin through all of the queued events when your web service request returns, and ignore all but the last one.
  • gaurachit's avatar
    gaurachit
    Channel Surfer
    "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?
  • gaurachit's avatar
    gaurachit
    Channel Surfer
    "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
  • "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()).
  • 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
  • "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.
  • gaurachit's avatar
    gaurachit
    Channel Surfer
    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.