issue with qupdate and QEvent::ignore

50 views
Skip to first unread message

Michael Lawrence

unread,
Feb 13, 2013, 12:45:03 AM2/13/13
to cra...@googlegroups.com
Hey guys,

Not sure why ignoring a QEvent removes the update request from the queue, but I've managed to get things to work by simply calling event$ignore() first, then calling qupdate().

If you have any more issues with event propagation, please let me know.

Michael

Marie Vendettuoli

unread,
Feb 13, 2013, 4:12:04 PM2/13/13
to cra...@googlegroups.com
Hi Michael - could you give a working example? I am having trouble getting the event$ignore()/qupdate() combo to allow default qscatter activity in the example I provided yesterday [[reproduced below]]. Thanks much


#Why doesn't this work? I want "T" to move the red line up (new 
#behavior) *and* display shift-T in upper right corner (default 
#behavior)

qiris <- qdata(iris)
hline <- 2.0

mykeypress <- function(layer, event){
  print('do something I want!')
  if(match_key('T')){
    hline <<- hline + .2
    qupdate(new)
  }
  event$ignore()
}

p <- qscatter(data = qiris, x = Sepal.Length, y = Sepal.Width)


mydrawingFun <- function(layer, painter){
  qdrawLine(painter, x = p$meta$limits[,1], y = hline, stroke = 'red')
}
new <- qlayer(paintFun = mydrawingFun, keyPressFun = mykeypress, 
              limits = qrect(p$meta$limits))
p$layerList[[1]][1,2] <- new
sync_limits(p$meta, new)


print(p)

--
You received this message because you are subscribed to the Google Groups "cranvas" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cranvas+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael Lawrence

unread,
Feb 13, 2013, 4:40:35 PM2/13/13
to cra...@googlegroups.com
Just move event$ignore() earlier in the handler, like:

mykeypress <- function(layer, event){
  print('do something I want!')
  event$ignore()
  if(match_key('T')){
    hline <<- hline + .2
    qupdate(new)
  }
}

At least, that seemed to get the line to move when I tried it last night.

Heike Hofmann

unread,
Feb 13, 2013, 5:20:20 PM2/13/13
to cra...@googlegroups.com
Michael,

could you send us your sessioninfo? We have just been trying out the code, and moving the event$ignore() doesn't change any of the behavior ... i.e. the line moves up for 't's, but any other key events get ignored 
(we = Di, Marie, Yihui, Tengfei and me)

Heike

Marie Vendettuoli

unread,
Feb 13, 2013, 5:21:33 PM2/13/13
to cra...@googlegroups.com
Yeah we don't have issues with the line moving, what we're really interested in is retaining the default qscatter interaction handler. 

In this example, the qscatter behavior of displaying the key event in the right corner is suppressed. This is unexpected (and unwanted)

Michael Lawrence

unread,
Feb 13, 2013, 5:42:38 PM2/13/13
to cra...@googlegroups.com
Oh ok. I am not familiar enough with cranvas to notice these things. The thing is that mouse handling and keyboard handling are different. The key presses are only delivered to the layer with the keyboard focus. This makes sense to me; since keyboard interactions are not graphical (so layering does not make sense). So forwarding keyboard events is not so easy. The best way forward is probably to use a single keyboard handling layer, which would support registration of key handlers, purely in R, outside of Qt. This API could support some conveniences; for example, handlers could be registered for specific keys. In general, I would recommend abstracting away as many qtpaint details as possible in your plotting code.

Michael

Dianne Cook

unread,
Feb 13, 2013, 5:26:55 PM2/13/13
to cra...@googlegroups.com
So an example is that for the scatterplot, it is no longer possible to change the size of the points using up/down arrows; or +/- for alpha blending
---------------------------
Di Cook




Reply all
Reply to author
Forward
0 new messages