source: trunk/as3/com/jeroenwijering/views/RightclickView.as @ 30

Revision 30, 1.9 KB checked in by jeroen, 5 years ago (diff)

removed keyboardview

  • Property svn:executable set to *
Line 
1/**
2* Interface for the rightclick menu.
3**/
4package com.jeroenwijering.views {
5
6
7import flash.events.ContextMenuEvent;
8import flash.net.navigateToURL;
9import flash.net.URLRequest;
10import flash.ui.ContextMenu;
11import flash.ui.ContextMenuItem;
12import com.jeroenwijering.player.View;
13
14
15public class RightclickView {
16
17
18        /** Reference to the MVC view. **/
19        private var view:View;
20        /** Reference to the contextmenu. **/
21        private var context:ContextMenu;
22
23
24        /** Contructor; sets up rightclick menu. **/
25        public function RightclickView(vie:View) {
26                view = vie;
27                context = new ContextMenu();
28                context.hideBuiltInItems();
29                view.skin.contextMenu = context;
30                addItem('Toggle Playback Quality',qualityHandler);
31                addItem('Toggle Captions Display',captionHandler);
32                try {
33                        var dps = view.skin.stage['displayState'];
34                } catch (err:Error) {}
35                if(view.config['fullscreen'] == true && dps != undefined) {
36                        addItem('Toggle Fullscreen Mode',fullscreenHandler);
37                }
38                if(view.config['abouttext']) {
39                        addItem(view.config['abouttext'],aboutHandler);
40                } else {
41                        addItem('About '+view.config['player']+'...',aboutHandler);
42                }
43        };
44
45
46        /** Add a custom menu item. **/
47        private function addItem(txt:String,hdl:Function) {
48                var itm = new ContextMenuItem(txt);
49                itm.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,hdl);
50                itm.separatorBefore = true;
51                context.customItems.push(itm);
52        };
53
54
55        /** Toggle the fullscreen mode. **/
56        private function fullscreenHandler(evt:ContextMenuEvent) {
57                view.sendEvent('fullscreen');
58        };
59
60
61        /** Toggle the smoothing mode. **/
62        private function qualityHandler(evt:ContextMenuEvent) {
63                view.sendEvent('quality');
64        };
65
66
67        /** Toggle the fullscreen mode. **/
68        private function captionHandler(evt:ContextMenuEvent) {
69                view.sendEvent('caption');
70        };
71
72
73        /** jump to the about page. **/
74        private function aboutHandler(evt:ContextMenuEvent) {
75                navigateToURL(new URLRequest(view.config['aboutlink']),'_blank');
76        };
77
78
79};
80
81
82}
Note: See TracBrowser for help on using the repository browser.