OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library slider_sample; | |
6 | |
7 import 'dart:html'; | |
8 import '../ui_lib/view/view.dart'; | |
9 | |
10 const menuItems = const["Apple", "Banana", "Cherry", "Durian"]; | |
11 | |
12 main() { | |
13 var sliderMenu = new SliderMenu(menuItems, (selectedText) { | |
14 displaySelection(selectedText); | |
15 }); | |
16 query("#menu").nodes.add(sliderMenu.node); | |
17 | |
18 query('#next').on.click.add((e) { | |
19 sliderMenu.selectNext(true); | |
20 }); | |
21 | |
22 query('#prev').on.click.add((e) { | |
23 sliderMenu.selectPrevious(true); | |
24 }); | |
25 | |
26 document.on.keyDown.add((KeyboardEvent event) { | |
27 switch (event.keyIdentifier) { | |
28 case KeyName.LEFT: | |
29 sliderMenu.selectPrevious(true); | |
30 break; | |
31 case KeyName.RIGHT: | |
32 sliderMenu.selectNext(true); | |
33 break; | |
34 } | |
35 }); | |
36 | |
37 sliderMenu.enterDocument(); | |
38 } | |
39 | |
40 void displaySelection(String selectedText) { | |
41 query("#notes").text = "Selection: ${selectedText}"; | |
42 } | |
OLD | NEW |