]> git.saurik.com Git - wxWidgets.git/blame - src/common/uiactioncmn.cpp
Use the same logic for closing dialogs as for handling Escape key.
[wxWidgets.git] / src / common / uiactioncmn.cpp
CommitLineData
a02a5cfc
KO
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/common/uiactioncmn.cpp
3// Purpose: wxUIActionSimulator common implementation
571d991b 4// Author: Kevin Ollivier, Steven Lamerton, Vadim Zeitlin
a02a5cfc
KO
5// Modified by:
6// Created: 2010-03-06
7// RCS-ID: $Id: menu.cpp 54129 2008-06-11 19:30:52Z SC $
8// Copyright: (c) Kevin Ollivier
571d991b
VZ
9// (c) 2010 Steven Lamerton
10// (c) 2010 Vadim Zeitlin
a02a5cfc
KO
11// Licence: wxWindows licence
12/////////////////////////////////////////////////////////////////////////////
13
14#include "wx/wxprec.h"
15
9b7e0226
VZ
16#if wxUSE_UIACTIONSIMULATOR
17
a02a5cfc
KO
18#include "wx/uiaction.h"
19
9b7e0226 20bool wxUIActionSimulator::MouseClick(int button)
a02a5cfc
KO
21{
22 MouseDown(button);
23 MouseUp(button);
9b7e0226 24
a02a5cfc
KO
25 return true;
26}
27
9b7e0226 28bool wxUIActionSimulator::MouseDblClick(int button)
a02a5cfc
KO
29{
30 MouseDown(button);
31 MouseUp(button);
32 MouseDown(button);
33 MouseUp(button);
9b7e0226 34
a02a5cfc
KO
35 return true;
36}
37
571d991b
VZ
38bool
39wxUIActionSimulator::MouseDragDrop(long x1, long y1, long x2, long y2,
40 int button)
a02a5cfc
KO
41{
42 MouseMove(x1, y1);
43 MouseDown(button);
9b7e0226 44 MouseMove(x2, y2);
a02a5cfc 45 MouseUp(button);
9b7e0226 46
a02a5cfc
KO
47 return true;
48}
49
571d991b
VZ
50bool
51wxUIActionSimulator::Key(int keycode, int modifiers, bool isDown)
52{
53 wxASSERT_MSG( !(modifiers & wxMOD_CONTROL),
54 "wxMOD_CONTROL is not implemented, use wxMOD_CMD instead" );
55 wxASSERT_MSG( (modifiers & wxMOD_ALTGR) != wxMOD_ALTGR,
56 "wxMOD_ALTGR is not implemented" );
57 wxASSERT_MSG( !(modifiers & wxMOD_META ),
58 "wxMOD_META is not implemented" );
59 wxASSERT_MSG( !(modifiers & wxMOD_WIN ),
60 "wxMOD_WIN is not implemented" );
61
62 return DoKey(keycode, modifiers, isDown);
63}
64
65bool wxUIActionSimulator::Char(int keycode, int modifiers)
66{
67 Key(keycode, modifiers, true);
68 Key(keycode, modifiers, false);
69
70 return true;
71}
72
73bool wxUIActionSimulator::Text(const char *s)
a02a5cfc 74{
571d991b
VZ
75 while ( *s != '\0' )
76 {
77 const char ch = *s++;
78
79 wxASSERT_MSG( ch, "Only letters are allowed" );
80
81 if ( !Char(ch, isupper(ch) ? wxMOD_SHIFT : 0) )
82 return false;
83 }
9b7e0226 84
a02a5cfc 85 return true;
9b7e0226
VZ
86}
87
88#endif // wxUSE_UIACTIONSIMULATOR