Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: ui/base/accelerator_manager.h

Issue 8695005: Move accelerator related files to ui/base/accelerators (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura_shell/shell_accelerator_filter.cc ('k') | ui/base/accelerator_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_BASE_ACCELERATOR_MANAGER_H_
6 #define UI_BASE_ACCELERATOR_MANAGER_H_
7 #pragma once
8
9 #include <list>
10 #include <map>
11
12 #include "base/basictypes.h"
13 #include "ui/base/models/accelerator.h"
14 #include "ui/base/ui_export.h"
15
16 namespace ui {
17
18 // The AcceleratorManger is used to handle keyboard accelerators.
19 class UI_EXPORT AcceleratorManager {
20 public:
21 AcceleratorManager();
22 ~AcceleratorManager();
23
24 // Register a keyboard accelerator for the specified target. If multiple
25 // targets are registered for an accelerator, a target registered later has
26 // higher priority.
27 // Note that we are currently limited to accelerators that are either:
28 // - a key combination including Ctrl or Alt
29 // - the escape key
30 // - the enter key
31 // - any F key (F1, F2, F3 ...)
32 // - any browser specific keys (as available on special keyboards)
33 void Register(const Accelerator& accelerator, AcceleratorTarget* target);
34
35 // Unregister the specified keyboard accelerator for the specified target.
36 void Unregister(const Accelerator& accelerator, AcceleratorTarget* target);
37
38 // Unregister all keyboard accelerator for the specified target.
39 void UnregisterAll(AcceleratorTarget* target);
40
41 // Activate the target associated with the specified accelerator.
42 // First, AcceleratorPressed handler of the most recently registered target
43 // is called, and if that handler processes the event (i.e. returns true),
44 // this method immediately returns. If not, we do the same thing on the next
45 // target, and so on.
46 // Returns true if an accelerator was activated.
47 bool Process(const Accelerator& accelerator);
48
49 // Returns the AcceleratorTarget that should be activated for the specified
50 // keyboard accelerator, or NULL if no view is registered for that keyboard
51 // accelerator.
52 AcceleratorTarget* GetCurrentTarget(const Accelerator& accelertor) const;
53
54 private:
55 // The accelerators and associated targets.
56 typedef std::list<AcceleratorTarget*> AcceleratorTargetList;
57 typedef std::map<Accelerator, AcceleratorTargetList> AcceleratorMap;
58 AcceleratorMap accelerators_;
59
60 DISALLOW_COPY_AND_ASSIGN(AcceleratorManager);
61 };
62
63 } // namespace ui
64
65 #endif // UI_BASE_ACCELERATOR_MANAGER_H_
OLDNEW
« no previous file with comments | « ui/aura_shell/shell_accelerator_filter.cc ('k') | ui/base/accelerator_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698