[comp.sys.amiga.programmer] RMB question

mike@zorch.SF-Bay.ORG (Mike Smithwick) (05/08/91)

[]

Is there an easy and legal way to catch a right-mouse button event under
intuition while still having access to the menus (since RMBTRAP traps
the right-button before the menu stuff could get it).


mike
 

-- 
"There is no problem to big that can't be solved with high explosives"-Rush

Mike Smithwick - ames!zorch!mike

peter@cbmvax.commodore.com (Peter Cherna) (05/09/91)

In article <1991May8.155337.5049@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
>[]
>
>Is there an easy and legal way to catch a right-mouse button event under
>intuition while still having access to the menus (since RMBTRAP traps
>the right-button before the menu stuff could get it).

MENUVERIFY will let you know when the menu button is pressed while
menus are in use.  I forget if Intuition sends MENUVERIFY when
a menu key-equivalent is typed, though.

>mike

     Peter
--
Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.
{uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"If all you have is a hammer, everything looks like a nail."

bombadil@diku.dk (Kristian Nielsen) (05/09/91)

mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:

>[]

>Is there an easy and legal way to catch a right-mouse button event under
>intuition while still having access to the menus (since RMBTRAP traps
>the right-button before the menu stuff could get it).

  If what you want to do is to be able to detect when the user brings up the
menu-bar, you should probably use the MENUVERIFY IDCMP-flag (which is
totally legal, as long as you watch out for deadlocks/mousefreezing, which
is bad in pre-2.0). This way you can respond to the button yourself, and let
intuition handle the menus afterwards.
  If, on the other hand you are after the sort of thing that Dpaint does,
you could switch RMBTRAP on and off using SetIDCMP() (or something similar).
Simply request MOUSEMOVE, and when the mouse gets over the titlebar,
de-activate the RMBTRAP. Now that I think of it, I'm not fully sure that
RMBTRAP is an IDCMP-flag, but if it is, this is also very legal. (DPaint
also uses MENUVERIFY to fix the colors for the menu).

>mike
> 

>-- 
>"There is no problem to big that can't be solved with high explosives"-Rush

>Mike Smithwick - ames!zorch!mike

	Hope this helps,

	- Kristian.

jpotter@ucs.adelaide.edu.au (Jonathan Potter) (05/09/91)

In article <1991May8.155337.5049@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
>[]
>
>Is there an easy and legal way to catch a right-mouse button event under
>intuition while still having access to the menus (since RMBTRAP traps
>the right-button before the menu stuff could get it).

One way to do it would be to have RMBTRAP set, then when you get a MENUDOWN
message, quickly clear the RMBTRAP flag of the window and send Intuition a
MENUDOWN message yourself. Kludgy, I know, but its the only way I can think
of doing it.

Jon

-- 
| Jonathan Potter |                                | I'd really like to      |
| P.O. Box 289    | jpotter@guests.adelaide.edu.au |   change the world...   |
| Goodwood, SA    | FidoNet : 3:680/829            | But they won't give me  |
| Australia  5034 |                                |   the source code.      |

mike@zorch.SF-Bay.ORG (Mike Smithwick) (05/11/91)

In article <21412@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes:
>In article <1991May8.155337.5049@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
<>[]
<>
<>Is there an easy and legal way to catch a right-mouse button event under
<>intuition while still having access to the menus (since RMBTRAP traps
<>the right-button before the menu stuff could get it).
<
<MENUVERIFY will let you know when the menu button is pressed while
<menus are in use.  I forget if Intuition sends MENUVERIFY when
<a menu key-equivalent is typed, though.
<
<>mike
<
<     Peter
<--
<Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.

Trouble with MENUVERIFY is that I get only a single message. I need to know
both MENUDOWN and MENUUP events which MENUVERIFY won't give.

mike
-- 
"There is no problem to big that can't be solved with high explosives"-Rush

Mike Smithwick - ames!zorch!mike

baxter_a@wehi.dn.mu.oz (05/11/91)

In article <21412@cbmvax.commodore.com>, peter@cbmvax.commodore.com (Peter Cherna) writes:
> In article <1991May8.155337.5049@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
>>[]
>>
>>Is there an easy and legal way to catch a right-mouse button event under
>>intuition while still having access to the menus (since RMBTRAP traps
>>the right-button before the menu stuff could get it).
> 
> MENUVERIFY will let you know when the menu button is pressed while
> menus are in use.  I forget if Intuition sends MENUVERIFY when
> a menu key-equivalent is typed, though.
> 

Yes it does.

Important to turn it off if the system might want to stick up an AutoRequest(),
too.

Regards Alan

mykes@amiga0.SF-Bay.ORG (Mike Schwartz) (05/12/91)

In article <1991May11.010739.24499@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
>In article <21412@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes:
>>In article <1991May8.155337.5049@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
><>[]
><>
><>Is there an easy and legal way to catch a right-mouse button event under
><>intuition while still having access to the menus (since RMBTRAP traps
><>the right-button before the menu stuff could get it).
><
><MENUVERIFY will let you know when the menu button is pressed while
><menus are in use.  I forget if Intuition sends MENUVERIFY when
><a menu key-equivalent is typed, though.
><
><>mike
><
><     Peter
><--
><Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.
>
>Trouble with MENUVERIFY is that I get only a single message. I need to know
>both MENUDOWN and MENUUP events which MENUVERIFY won't give.
>
>mike
>-- 
>"There is no problem to big that can't be solved with high explosives"-Rush
>
>Mike Smithwick - ames!zorch!mike
>

You can use:

; POTGOR	equ	$dff016

_RightMouseButton
		btst	#2,POTGOR	; right mouse button status
		beq	.rmbDown
.rmbUp		moveq	#0,d0
		rts
.rmbDown	moveq	#-1,d0
		rts

to check for the right mouse button.

I know about using hard coded numbers instead of labels, but remember
that this code is just for illustration purposes (i.e. code it as YOU
see fit).

You would use a routine like this after getting your MenuVerify and only
when you know that yours is the front screen.  This interferes in NO way
with the OS.

--
****************************************************
* I want games that look like Shadow of the Beast  *
* but play like Leisure Suit Larry.                *
****************************************************

jsmoller@jsmami.UUCP (Jesper Steen Moller) (05/12/91)

In article <1991May11.010739.24499@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
> 
> Trouble with MENUVERIFY is that I get only a single message. I need to know
> both MENUDOWN and MENUUP events which MENUVERIFY won't give.

I think toggling RMPTRAP (to ON!) when you get the MENUVERIFY will do you.
Then, when you get the MENUUP, you toggle again.... I'm not sure whether this
method is bullet-proof, though!
 
> Mike Smithwick - ames!zorch!mike

JSMoller

--                     __
Jesper Steen Moller   ///  VOICE: +45 31 62 46 45
Maglemosevej 52  __  ///  USENET: cbmehq!cbmdeo!jsmami!jsmoller
DK-2920 Charl    \\\///  FIDONET: 2:231/84.45
Denmark           \XX/

rjc@geech.gnu.ai.mit.edu (Ray Cromwell) (05/12/91)

In article <mykes.2492@amiga0.SF-Bay.ORG> mykes@amiga0.SF-Bay.ORG (Mike Schwartz) writes:
>In article <1991May11.010739.24499@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
>>In article <21412@cbmvax.commodore.com> peter@cbmvax.commodore.com (Peter Cherna) writes:
>>>In article <1991May8.155337.5049@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
>><>[]
>><>
>><>Is there an easy and legal way to catch a right-mouse button event under
>><>intuition while still having access to the menus (since RMBTRAP traps
>><>the right-button before the menu stuff could get it).
>><
>><MENUVERIFY will let you know when the menu button is pressed while
>><menus are in use.  I forget if Intuition sends MENUVERIFY when
>><a menu key-equivalent is typed, though.
>><
>><>mike
>><
>><     Peter
>><--
>><Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.
>>
>>Trouble with MENUVERIFY is that I get only a single message. I need to know
>>both MENUDOWN and MENUUP events which MENUVERIFY won't give.
>>
>>mike
>>-- 
>>"There is no problem to big that can't be solved with high explosives"-Rush
>>
>>Mike Smithwick - ames!zorch!mike
>>
>
>You can use:
>
>; POTGOR	equ	$dff016
>
>_RightMouseButton
>		btst	#2,POTGOR	; right mouse button status
>		beq	.rmbDown
>.rmbUp		moveq	#0,d0
>		rts
>.rmbDown	moveq	#-1,d0
>		rts
>
>to check for the right mouse button.
>
>I know about using hard coded numbers instead of labels, but remember
>that this code is just for illustration purposes (i.e. code it as YOU
>see fit).
>
>You would use a routine like this after getting your MenuVerify and only
>when you know that yours is the front screen.  This interferes in NO way
>with the OS.

   Besides this fact that this is illegal (you didn't Allocate the pot
bits nor did you use gameport.device) please don't use releases like
this, I'll explain why. Intuition allows keyboard shortcuts for the
mouse buttons (Alt-LAmiga=LMB Alt-RAmiga=RMB). Those great C= mice
break down a lot, particularly the mouse buttons. My LMB is slightly
broken and sometimes I have to use the keyboard shortcut. You're routine
kills my chances of using the keyboard or using any non-standard input
device/hack. Use the OS for stuff like this. There a few solutions to this
problem. 1) Install an input handler/commodity and watch RMB events.
2) Use RMBTRAP and then disable RMBTRAP, and fake a mouse  event on
intuition? Would this work?
3) SetMPort on input.device?

  There has to be an OS solution that is better than going to the
hardware.

>--
>****************************************************
>* I want games that look like Shadow of the Beast  *
>* but play like Leisure Suit Larry.                *
>****************************************************


--
/ INET:rjc@gnu.ai.mit.edu     *   // The opinions expressed here do not      \
| INET:r_cromwe@upr2.clu.net  | \X/  in any way reflect the views of my self.|
\ UUCP:uunet!tnc!m0023        *                                              /

peter@cbmvax.commodore.com (Peter Cherna) (05/13/91)

In article <1991May11.010739.24499@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
>Trouble with MENUVERIFY is that I get only a single message. I need to know
>both MENUDOWN and MENUUP events which MENUVERIFY won't give.

Crudely speaking, MENUVERIFY corresponds to MENUDOWN and MENUPICK to
MENUUP.

Normally, if you need to hear MENUUP and MENUDOWN, you don't also
need to hear MENUPICK.  That is to say, your program would have two
states, which the user might enter explicitly or implicitly (eg.
mouse position in DPaint).

You can set or clear RMBTRAP atomically to effect the state change.

>mike

     Peter
--
Peter Cherna, Operating Systems Development Group, Commodore-Amiga, Inc.
{uunet|rutgers}!cbmvax!peter    peter@cbmvax.commodore.com
My opinions do not necessarily represent the opinions of my employer.
"If all you have is a hammer, everything looks like a nail."