! Tests the ButtonAction for plot option (BUG 2868)
!
! @author  J. McCall
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  call setDatDir

  set inst "Try out the different functions for the mouse buttons."
  if interAct then
    invoke buttonActionList nxm.sys.libg.MPlot.buttonActionList
    set t:ButtonActionDescr {DEFAULT="use button default",NONE="no action",&
                             MENU="popup menu",MARK_MESSAGE="mark location", &
                             UNZOOM="Zoom Out"}
  
    pipe on
    panel/msgid=MAIN/setup/controls=gc
      gcontrol label macro "MACRO"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
      gcontrol text idtext "Instructions" "^inst" 24 10 /title
      
      plot/id=idplot/msgid=main/mtag={x=gc.prompt_x.value,y=gc.prompt_y.value} ^{datDir}.apenny.prm buttonaction={LMB=MENU,MMB=UNZOOM,RMB=MARK}
      gcontrol label  buttonact   "BUTTON ACTIONS" AlwaysOpen
      gcontrol choice lmb       "LMB:    " "^{buttonActionList}" "^{reg.idplot.buttonAction.lmb}"
      gcontrol choice mmb       "MMB:    " "^{buttonActionList}" "^{reg.idplot.buttonAction.mmb}"
      gcontrol choice rmb       "RMB:    " "^{buttonActionList}" "^{reg.idplot.buttonAction.rmb}"
      gcontrol label  markres   "MARK RESULTS" AlwaysOpen
      gcontrol prompt prompt_x "X Value" ""
      gcontrol prompt prompt_y "Y Value" ""
    
  endif
  
endmacro
!*************************************************************
procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name EQS "LMB" then
    set reg.idplot.buttonAction {LMB=^{msg.data}}
    set gc.idtext.value "The LMB button should now ^{ButtonActionDescr.^{msg.data}}."
  elseif msg.name EQS "MMB" then
    set reg.idplot.buttonAction {MMB=^{msg.data}}
    set gc.idtext.value "The MMB button should now ^{ButtonActionDescr.^{msg.data}}."

  elseif msg.name EQS "RMB" then
    set reg.idplot.buttonAction {RMB=^{msg.data}}
    set gc.idtext.value "The RMB button should now ^{ButtonActionDescr.^{msg.data}}."
  
  endif

return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
