Silverfrost Forums

Welcome to our forums

GET_MOUSE_POSITION@() alternative

22 Aug 2014 2:11 #14482

I was wondering of anybody could help me.. I have a relative complicates flow-sheeting application that has GET_MOUSE_POSITION@() at the core to select/move edit graphics objects. currently the specific active function it terminated using the right mouse key press. I t has been request that the ESC key be used as an additional alternative. I have tried the key monitoring technique posted elsewhere on the forum without success. I have seen that clearwin_info@() is recommended as a replacement but it does not seem to have the functionality i'm looking for.

here is my current function. it anybody could provide an alternative with additional keyboard scanning functionality it would be appreciated

 SUBROUTINE GET_MOUSE_POS_ORG(IX1, IY1, IRIGHTB_STAT, ILEFTB_STAT)

c ========================

  IMPLICIT NONE

  INCLUDE 'PARAM_ED.INC'

  INTEGER IX1, IY1, IRIGHTB_STAT, ILEFTB_STAT
  INTEGER*2 IH, IV, BUTTON_STATUS, ILEFTB, IRIGHTB, IBITZ, IBITZ2, 
 +        INTS

  ILEFTB = INTS(1)
  IRIGHTB = INTS(2)


  IRIGHTB_STAT = BUTTON_OFF
  ILEFTB_STAT = BUTTON_OFF
  CALL GET_MOUSE_POSITION@(IH, IV, BUTTON_STATUS)

c IBITZ = INTS(AND(BUTTON_STATUS, IRIGHTB)) IBITZ = AND(BUTTON_STATUS, IRIGHTB) IF (IBITZ .NE. 0) THEN IRIGHTB_STAT = BUTTON_ON ENDIF

c IBITZ2 = INTS(AND(BUTTON_STATUS, ILEFTB)) IBITZ2 = AND(BUTTON_STATUS, ILEFTB) IF (IBITZ2 .NE. 0) THEN ILEFTB_STAT = BUTTON_ON ENDIF

  IX1 = IH
  IY1 = IV

  END
22 Aug 2014 7:39 #14484

Steve,

Is it worth using Esc as an accelerator key, either established with %ac or add_accelerator@ ? Then you'd have a whole callback available to terminate your process. It might be worth putting the response to right-click in a function on its own, then you could call it in response to right-click OR use it as the callback to the Esc key accelerator.

Assuming that your graphics operation (the 'specific active function') begins with something (maybe a left-click) then that's the point where I would call add_accelerator@, and after the exit command, call remove_accelerator@. You will need the graphics window handle.

Eddie

30 Aug 2014 2:59 #14563

Eddie

worked like a dream. thanks for the help

steve

30 Aug 2014 4:18 #14564

It's nice to know that something I thought up as how I would attempt it works - it wasn't something I tested! presumably you went the add_accelerator@ ... remove_accelerator@ route.

You may also find it useful to change the cursor appearance at the beginning and end of the select-move-drop sequence (if you haven't already done so) as this looks very professional.

Eddie

30 Aug 2014 7:50 #14565

HI Eddie

using the accelerator key method was simple to implement

just add accelerator key and set a flag use the accelerator key callback to trip the flag use to the flag to set the button push flag

pseudo code

 call  SET_ESC_KEY(1)

10 continue CALL GET_MOUSE_POS(IXPOS, IYPOS, IRIGHTB, ILEFTB)

  CALL GET_ESC_KEY(IRIGHTB)

  IF (IRIGHTB .EQ. BUTTON_ON) GOTO 150

c c c

   goto 10

. 150 call SET_ESC_KEY(0)

c c all variable defined in include file and in common c

 SUBROUTINE SET_ESC_KEY(IMODE)

c ======================

  IMPLICIT NONE

  INCLUDE 'WINDOWSX.INC'
  INCLUDE 'PARAM_ED.INC'
  INCLUDE 'DNDWIN.INC'

  INTEGER IMODE
  EXTERNAL ESC_KEY_CB
  INTEGER ESC_KEY_CB

  IF (IMODE .EQ. 1) THEN
    ESC_ACTIVE_FLG = ITRUE

    CALL ADD_ACCELERATOR@(DND_MAIN_WIN_HANDLE, 'ESC', ESC_KEY_CB)
  ELSE

    CALL REMOVE_ACCELERATOR@(DND_MAIN_WIN_HANDLE, 'ESC')

  ENDIF

  END

  SUBROUTINE GET_ESC_KEY(IRIGHTB)

c =================

  IMPLICIT NONE

  INCLUDE 'PARAM_ED.INC'
  INCLUDE 'DNDWIN.INC'

  INTEGER IRIGHTB

  IF (ESC_ACTIVE_FLG .EQ. IFALSE) THEN
    IRIGHTB = BUTTON_ON

  ENDIF

  END


  INTEGER FUNCTIONESC_KEY_CB()

c =================

  IMPLICIT NONE

  INCLUDE 'PARAM_ED.INC'
  INCLUDE 'DNDWIN.INC'

  CALL EDIT_GET_LWO(ESC_KEY_CB)

  ESC_ACTIVE_FLG = IFALSE

  END
31 Aug 2014 10:09 #14568

Hi Steve,

Don't ESC_ACTIVE_FLG and BUTTON_ON (or is it IMODE?) do more-or-less the same job?

My first excursion into Clearwin+ had lots of state flags until I realised that the grey-control code often did the same job. Some of the flags used the convention 1='permit_action' whereas others used the convention 1='forbid_action', and it took me a long time and lots of frustration before I became consistent with the grey-control convention (1='permit_action').

Eddie

31 Aug 2014 12:34 #14571

I guess i could rationalise the code a little but experience has taught me to be paranoid about unwanted side effects. I will revisit he implementation to make it more generic so i can use it elsewhere.

i to use to get very confused with 0/1 settings so i have parametrised everything button_on/button_off grey_on/grey_off etc. it help to avoid mistakes and i think make the code a little easier to read

Please login to reply.