RPMG (version 2.2-2)

whichbutt: 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

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.

Details

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

See Also

rowBUTTONS, locator

Examples

Run this code
# NOT RUN {
###################  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)


# }

Run the code above in your browser using DataLab