Update NTK.
[nondaw.git] / FL / test_press.C
blob158b55ce6fd29e92a2363e1472172f81dc5b0762
2 /*******************************************************************************/
3 /* Copyright (C) 2008 Jonathan Moore Liles                                     */
4 /*                                                                             */
5 /* This program is free software; you can redistribute it and/or modify it     */
6 /* under the terms of the GNU General Public License as published by the       */
7 /* Free Software Foundation; either version 2 of the License, or (at your      */
8 /* option) any later version.                                                  */
9 /*                                                                             */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       */
12 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   */
13 /* more details.                                                               */
14 /*                                                                             */
15 /* You should have received a copy of the GNU General Public License along     */
16 /* with This program; see the file COPYING.  If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18 /*******************************************************************************/
20 /* Fl::test_shortcut() is broken for use in FL_PUSH handlers etc,
21  * because it relies on Fl::event_text(), which isn't cleared as it
22  * should be--and there's no official way to clear it. Therefore, we
23  * provide a test_press() function instead, which, unlike
24  * test_shortcut(), does not treat a missing FL_SHIFT as "don't care". */
26 #include <FL/Fl.H>
28 int
29 test_press ( unsigned long e )
31     if ( Fl::event_text()[0] )
32         ((char *)Fl::event_text())[0] = '\0';
34     if ( ! ( e & FL_SHIFT ) )
35         return Fl::test_shortcut( e ) && ! Fl::event_shift();
36     else
37         return Fl::test_shortcut( e );