Coverage for src/robotide/action/__init__.py: 100%

2 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-06 10:40 +0100

1# Copyright 2008-2015 Nokia Networks 

2# Copyright 2016- Robot Framework Foundation 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15 

16"""Module for handling UI actions. 

17 

18.. contents:: 

19 :depth: 2 

20 :local: 

21 

22Introduction 

23------------ 

24 

25This module is used both by the core application and plugins to create and 

26register menu entries, toolbar buttons and keyboard shortcuts. All these are 

27created using the `ActionInfo` and `SeparatorInfo` classes. 

28 

29Registering actions 

30------------------- 

31 

32Actions are registered by creating an instance of the `ActionInfo` class with 

33the needed data. After configuring the instance it can be registered. The core 

34application handles registration itself, but plugins should always use the 

35`pluginapi.Plugin.register_action` method. 

36 

37Menu separators 

38~~~~~~~~~~~~~~~ 

39 

40Menu separators are created using instances of the `SeparatorInfo` class.  

41They must be registered using the same methods as the `ActionInfo` instances.  

42 

43Registering multiple actions 

44~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

45 

46If there is a need to create a larger number of actions, it might be convenient 

47to use a simple DSL understood by the `ActionInfoCollection` factory method. 

48This factory creates a list containing `ActionInfo` and `SeparatorInfo` objects 

49which can be registered in a one go. 

50 

51Handling actions 

52---------------- 

53 

54When any of the registered user actions is executed, RIDE decides which 

55registered event handlers should be called. It is possible to register a handler 

56globally or so that it is called only when the plugin is considered active 

57(i.e. it has focus). 

58 

59The registering mechanism allows multiple handlers to be registered to the same 

60menu entry, toolbar button, or shortcut. It is thus possible that, for example, 

61one keyboard shortcut calls multiple handlers.  

62 

63It is also possible to enable/disable action's menu entry, toolbar button, 

64and shortcut by enabling/disabling those with `action.Action.enable` and  

65`action.Action.disable` methods. Action is returned by  

66`pluginapi.Plugin.register_action` method. 

67""" 

68 

69 

70from .action import action_factory 1ab

71from .actioninfo import action_info_collection, SeparatorInfo, ActionInfo 1ab