On Tue, May 21, 2002 at 09:53:45AM +0200, Marcus Lundblad wrote:
> I have 2 functions which I would like to change the binding of mouse
> button 2 on the root window like this:
>
> Mouse 2 R A HidePager
>
> AddToFunc HidePager "I" All ("FvwmPager") Stick off
> + "I" All ("FvwmPager") MoveToDesk 123
> + "I" Mouse 2 R A ShowPager
>
> AddToFunc ShowPager "I" All ("FvwmPager") Stick on
> + "I" Mouse 2 R A HidePager
>
>
> So that pressing button 2 will toggle.
> But this will not work, it seeems the last line tries to call the other
> function, because the cursor changes to an hour-glass for about 1 second
> (as if there's an infinity recursion that is interrupted).
>
> Is it not possible to use the Mouse command in functions like this?
> I didn't find anything about this in the man-page.
I don't know how it exactly works internally, but you can not
expect that changing bindings or functions works inside complex
functions. Anyway, there is a much simpler solution for what you
want to achieve. Take a look at Q 7.12 from the FAQ:
----------------------------------------------------------------------
7.12 Toggling windows on and off.
It is often desirable to have a menu item of perhaps a button in
FvwmButtons or FvwmWharf that launches an application when used
the first time and closes it if used a second time. Although it
is not obvious how to do this, it is possible. Let's assume you
need a menu item that toggles an FvwmConsole window on and off.
Then put the following lines in your .fvwm2rc:
AddToFunc ToggleFvwmConsole
+ I None (FvwmConsole) Module FvwmConsole
+ I Next (CurrentPage Visible FvwmConsole) Close
+ I Next (FvwmConsole) MoveToDesk
+ I Next (FvwmConsole) MoveToPage
+ I Next (FvwmConsole) Raise
AddToMenu <some menu>
+ "toggle FvwmConsole" Function ToggleFvwmConsole
Or if you prefer a button in the button bar:
*FvwmButtons(Action ToggleFvwmConsole)
The lines with MoveToDesk, MoveToPage and Raise will bring the
window to the top of the current page if it is not visible
instead of closing it.
If you want to toggle one specific window, e.g. an xterm, but
still want to have other xterms that are not toggled, you must
give the window an unique name:
AddToFunc ToggleXMessages
+ I None (XMessages) Exec ( TERM -T XMessages -n XMessages \
-e exec tail -f /var/adm/?* ~/.X.err )
+ I Next (XMessages) Close
Or for a toggling Netscape button:
AddToFunc ToggleNetscape
+ I None (Navigator) Exec exec netscape
+ I All (Navigator) Close
Keep in mind that these functions simply check if a window with
the specified name exists. They will happily close manually
opened windows or launch an application multiple times if the
application is slow to start (e.g. like netscape).
----------------------------------------------------------------------
Bye
Dominik ^_^ ^_^
--
Dominik Vogt, email: d.vogt_at_lifebits.de
LifeBits Aktiengesellschaft, Albrechtstr. 9, D-72072 Tuebingen
fon: ++49 (0) 7071/7965-0, fax: ++49 (0) 7071/7965-20
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Tue May 21 2002 - 05:52:13 BST