whichbutt | R Documentation |
Function to determine which button of the RPMG was selected during a graphics session.
whichbutt(v, buttons)
v |
list of x,y coordinates obtained from the locator() function |
buttons |
list of buttons set by the function rowBUTTONS |
whichbutt uses the geometry determined by rowButtons and a list of locator() points to return the buttons clicked on or, if none, 0.
Returns a vector of indexes to buttons selected by the user. Buttons are numebred 1-N so if a click is not on a button, zero is returned.
This function can be used to get interaction with predined buttons and non-button clicks using locator().
Jonathan M. Lees <jonathan.lees@unc.edu>
rowBUTTONS, locator
################### initial plot
plot(c(0,1), c(0,1))
###### set buttons
mybutts = c("DONE", "REFRESH", "rainbow", "topo", "terrain", "CONT",
"XSEC","PS" )
colabs = rep(1, length=length(mybutts))
pchlabs = rep(0,length(mybutts))
###### set button geometry
buttons = rowBUTTONS(mybutts, col=colabs, pch=pchlabs)
######## user clicks on plot. When locator finishes, whichbutt
######## determines which buttons were selected and returns the vector
L = locator()
K = whichbutt(L, buttons)
print(K)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.