whichbutt {RPMG}R Documentation

Determines which button was selected in RPGM

Description

Function to determine which button of the RPMG was selected during a graphics session.

Usage

whichbutt(v, buttons)

Arguments

v

list of x,y coordinates obtained from the locator() function

buttons

list of buttons set by the function rowBUTTONS

Details

whichbutt uses the geometry determined by rowButtons and a list of locator() points to return the buttons clicked on or, if none, 0.

Value

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.

Note

This function can be used to get interaction with predined buttons and non-button clicks using locator().

Author(s)

Jonathan M. Lees <jonathan.lees@unc.edu>

See Also

rowBUTTONS, locator

Examples


###################  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)



[Package RPMG version 2.2-7 Index]