opal 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +10 -1
- data/.gitmodules +0 -0
- data/Opalfile +371 -0
- data/README.md +45 -0
- data/Rakefile +237 -34
- data/VERSION +1 -1
- data/bin/opal +13 -0
- data/demos/apps/browser_demo/index.html +11 -0
- data/demos/apps/browser_demo/lib/browser_demo.rb +31 -0
- data/demos/apps/simple_opal/Opalfile +13 -0
- data/demos/apps/simple_opal/index.html +11 -0
- data/demos/apps/simple_opal/lib/app_controller.rb +62 -0
- data/demos/apps/simple_opal/lib/main_window.rb +146 -0
- data/demos/browser/request/index.html +52 -0
- data/demos/browser/request/request.rb +48 -0
- data/gen/browser/__PROJECT_NAME__/index.html +10 -0
- data/gen/browser/__PROJECT_NAME__/lib/__PROJECT_NAME__.rb +1 -0
- data/lib/opal.rb +48 -3
- data/lib/opal/builders/base.rb +50 -0
- data/lib/opal/builders/css.rb +46 -0
- data/lib/opal/builders/javascript.rb +44 -0
- data/lib/opal/builders/opal.rb +79 -0
- data/lib/opal/builders/ruby.rb +50 -0
- data/lib/opal/builders/ruby/generate.rb +1851 -0
- data/lib/opal/builders/ruby/nodes.rb +210 -0
- data/lib/opal/builders/ruby/ruby.rb +916 -0
- data/lib/opal/builders/ruby/ruby_parser.rb +6008 -0
- data/lib/opal/builders/ruby/ruby_parser.rb.y +1451 -0
- data/lib/opal/models/build_item.rb +104 -0
- data/lib/opal/models/hash_struct.rb +40 -0
- data/lib/opal/models/project.rb +215 -0
- data/lib/opal/models/struct_accessors.rb +58 -0
- data/lib/opal/models/target.rb +176 -0
- data/lib/opal/opal/env/console.rb +66 -0
- data/lib/opal/opal/env/fs.rb +98 -0
- data/lib/opal/opal/env/object.rb +48 -0
- data/lib/opal/opal/environment.rb +139 -0
- data/lib/opal/opal/gen.rb +62 -0
- data/lib/opal/opal/opal.rb +68 -0
- data/lib/opal/opal/repl.rb +38 -0
- data/lib/opal/opalfile/dsl.rb +62 -0
- data/lib/opal/opalfile/opalfile.rb +133 -0
- data/lib/opal/opalfile/task.rb +96 -0
- data/lib/opal/opalfile/task_manager.rb +63 -0
- data/lib/opal/opalfile/task_scope.rb +52 -0
- data/lib/opal/rack/app_server.rb +119 -0
- data/opals/aristo/README.md +16 -0
- data/opals/browser/Opalfile +11 -0
- data/opals/browser/README.md +146 -0
- data/opals/browser/SIZZLE_LICESNSE.txt +148 -0
- data/opals/browser/lib/browser.rb +118 -0
- data/opals/browser/lib/browser/builder.rb +41 -0
- data/opals/browser/lib/browser/canvas_context.rb +115 -0
- data/opals/browser/lib/browser/dimensions.rb +50 -0
- data/opals/browser/lib/browser/document.rb +146 -0
- data/opals/browser/lib/browser/element.rb +487 -0
- data/opals/browser/lib/browser/element/attributes.rb +88 -0
- data/opals/browser/lib/browser/element/css.rb +290 -0
- data/opals/browser/lib/browser/element/form.rb +146 -0
- data/opals/browser/lib/browser/event/dom_events.rb +81 -0
- data/opals/browser/lib/browser/event/event.rb +177 -0
- data/opals/browser/lib/browser/event/trigger_events.rb +53 -0
- data/opals/browser/lib/browser/geometry.rb +97 -0
- data/opals/browser/lib/browser/json.rb +32 -0
- data/opals/browser/lib/browser/json_parse.js +321 -0
- data/opals/browser/lib/browser/request/request.rb +201 -0
- data/opals/browser/lib/browser/sizzle.js +1068 -0
- data/opals/browser/lib/browser/string.rb +42 -0
- data/opals/browser/lib/browser/touch.rb +37 -0
- data/{runtime/yaml.js → opals/browser/lib/browser/vml_context.js} +8 -8
- data/opals/browser/lib/browser/window.rb +36 -0
- data/opals/browser/spec/browser/browser_detection_spec.rb +7 -0
- data/opals/browser/spec/document/aref_spec.rb +110 -0
- data/opals/browser/spec/document/ready_spec.rb +16 -0
- data/opals/browser/spec/element/body_spec.rb +11 -0
- data/opals/browser/spec/element/clear_spec.rb +26 -0
- data/opals/browser/spec/element/empty_spec.rb +29 -0
- data/opals/browser/spec/element/has_class_spec.rb +40 -0
- data/opals/browser/spec/element/hidden_spec.rb +23 -0
- data/opals/browser/spec/element/hide_spec.rb +31 -0
- data/opals/browser/spec/element/remove_spec.rb +25 -0
- data/opals/browser/spec/element/show_spec.rb +31 -0
- data/opals/browser/spec/element/style_spec.rb +69 -0
- data/opals/browser/spec/element/toggle_spec.rb +31 -0
- data/opals/browser/spec/element/visible_spec.rb +23 -0
- data/opals/browser/spec/spec_helper.rb +1 -0
- data/opals/cherry_kit/Opalfile +6 -0
- data/opals/cherry_kit/bin/cherry_kit.rb +11 -0
- data/opals/cherry_kit/lib/cherry_kit.rb +29 -0
- data/opals/foundation/Opalfile +11 -0
- data/opals/foundation/bin/foundation.rb +12 -0
- data/opals/foundation/lib/foundation.rb +32 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/outline_view.rb +57 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/table_column.rb +59 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/table_header_view.rb +34 -0
- data/opals/foundation/lib/foundation/__table_view_desktop/table_view.rb +304 -0
- data/opals/foundation/lib/foundation/controllers/array_controller.rb +54 -0
- data/opals/foundation/lib/foundation/controllers/controller.rb +74 -0
- data/opals/foundation/lib/foundation/controllers/controller_selection_proxy.rb +67 -0
- data/opals/foundation/lib/foundation/controllers/object_controller.rb +145 -0
- data/opals/foundation/lib/foundation/controllers/view.rb +40 -0
- data/opals/foundation/lib/foundation/core/application.rb +476 -0
- data/opals/foundation/lib/foundation/core/attributes.rb +146 -0
- data/opals/foundation/lib/foundation/core/bindings.rb +125 -0
- data/opals/foundation/lib/foundation/core/builder.rb +101 -0
- data/opals/foundation/lib/foundation/core/event.rb +112 -0
- data/opals/foundation/lib/foundation/core/index_path.rb +49 -0
- data/opals/foundation/lib/foundation/core/index_set.rb +97 -0
- data/opals/foundation/lib/foundation/core/notification.rb +113 -0
- data/opals/foundation/lib/foundation/core/observable.rb +275 -0
- data/opals/foundation/lib/foundation/core/observable_array.rb +30 -0
- data/opals/foundation/lib/foundation/core/responder.rb +85 -0
- data/opals/foundation/lib/foundation/core/run_loop.rb +89 -0
- data/opals/foundation/lib/foundation/core/touch.rb +95 -0
- data/opals/foundation/lib/foundation/gestures/gesture_recognizer.rb +35 -0
- data/opals/foundation/lib/foundation/rendering/render_context.rb +100 -0
- data/opals/foundation/lib/foundation/rendering/renderer.rb +137 -0
- data/opals/foundation/lib/foundation/rendering/root_theme.rb +77 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/button.rb +62 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/control.rb +72 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/label.rb +54 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/scroller.rb +58 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/slider.rb +72 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/table_view.rb +97 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/text_field.rb +55 -0
- data/opals/foundation/lib/foundation/rendering/root_theme/view.rb +81 -0
- data/opals/foundation/lib/foundation/rendering/theme.rb +38 -0
- data/opals/foundation/lib/foundation/table_view/cell.rb +39 -0
- data/opals/foundation/lib/foundation/table_view/table.rb +171 -0
- data/opals/foundation/lib/foundation/views/button.rb +63 -0
- data/opals/foundation/lib/foundation/views/checkbox.rb +28 -0
- data/opals/foundation/lib/foundation/views/clip.rb +47 -0
- data/opals/foundation/lib/foundation/views/control.rb +199 -0
- data/opals/foundation/lib/foundation/views/label.rb +54 -0
- data/opals/foundation/lib/foundation/views/scroll.rb +294 -0
- data/opals/foundation/lib/foundation/views/scroll_view_desktop.rb +152 -0
- data/opals/foundation/lib/foundation/views/scroller.rb +54 -0
- data/opals/foundation/lib/foundation/views/slider.rb +93 -0
- data/opals/foundation/lib/foundation/views/text_field.rb +83 -0
- data/opals/foundation/lib/foundation/views/view.rb +426 -0
- data/opals/foundation/lib/foundation/windows/window.rb +191 -0
- data/opals/foundation/resources/button/button.css +23 -0
- data/{runtime/init.js → opals/foundation/resources/foundation.css} +27 -33
- data/opals/foundation/resources/scroll/scroll.css +22 -0
- data/opals/foundation/resources/scroll_view/scroll_view.css +3 -0
- data/opals/foundation/resources/scroll_view/scroller.css +3 -0
- data/opals/foundation/resources/slider/regular/slider.css +3 -0
- data/opals/foundation/resources/slider/slider.css +27 -0
- data/opals/foundation/resources/table_view/outline_view.css +3 -0
- data/opals/foundation/resources/table_view/table_view.css +15 -0
- data/opals/foundation/resources/text_field/text_field.css +71 -0
- data/opals/foundation/spec/spec_helper.rb +1 -0
- data/opals/foundation/spec/system/attributes/get_attribute_spec.rb +69 -0
- data/opals/foundation/spec/system/attributes/get_path_spec.rb +44 -0
- data/opals/foundation/spec/system/attributes/set_path_spec.rb +24 -0
- data/opals/foundation/spec/system/attributes/set_spec.rb +58 -0
- data/opals/foundation/spec/system/bindings/bindings.rb +85 -0
- data/opals/foundation/spec/system/key_value_binding/bind_spec.rb +43 -0
- data/opals/foundation/spec/system/observable/dependant_keys_spec.rb +74 -0
- data/opals/foundation/spec/system/observable/observe_spec.rb +292 -0
- data/opals/foundation/spec/system/observable/remove_observer_spec.rb +60 -0
- data/opals/opal/Opalfile +14 -0
- data/opals/opal/spec/core/array/append_spec.rb +30 -0
- data/opals/opal/spec/core/array/assoc_spec.rb +29 -0
- data/opals/opal/spec/core/array/at_spec.rb +37 -0
- data/opals/opal/spec/core/array/clear_spec.rb +22 -0
- data/opals/opal/spec/core/array/collect_bang_spec.rb +27 -0
- data/opals/opal/spec/core/array/collect_spec.rb +27 -0
- data/opals/opal/spec/core/array/compact_spec.rb +15 -0
- data/opals/opal/spec/core/array/concat_spec.rb +15 -0
- data/opals/opal/spec/core/array/constructor_spec.rb +14 -0
- data/opals/opal/spec/core/array/each_spec.rb +9 -0
- data/opals/opal/spec/core/array/element_reference_spec.rb +4 -0
- data/opals/opal/spec/core/array/first_spec.rb +35 -0
- data/opals/opal/spec/core/array/include_spec.rb +9 -0
- data/opals/opal/spec/core/array/map_spec.rb +31 -0
- data/opals/opal/spec/core/builtin_constants/builtin_constants_spec.rb +7 -0
- data/opals/opal/spec/core/false/and_spec.rb +10 -0
- data/opals/opal/spec/core/false/inspect_spec.rb +6 -0
- data/opals/opal/spec/core/false/or_spec.rb +10 -0
- data/opals/opal/spec/core/false/to_s_spec.rb +6 -0
- data/opals/opal/spec/core/false/xor_spec.rb +10 -0
- data/opals/opal/spec/core/file/join_spec.rb +19 -0
- data/opals/opal/spec/core/kernel/instance_eval_spec.rb +0 -0
- data/opals/opal/spec/core/kernel/loop_spec.rb +24 -0
- data/opals/opal/spec/core/kernel/raise_spec.rb +0 -0
- data/opals/opal/spec/core/module/attr_accessor_spec.rb +28 -0
- data/opals/opal/spec/core/number/lt_spec.rb +12 -0
- data/opals/opal/spec/core/true/and_spec.rb +10 -0
- data/opals/opal/spec/core/true/inspect_spec.rb +6 -0
- data/opals/opal/spec/core/true/or_spec.rb +10 -0
- data/opals/opal/spec/core/true/to_s_spec.rb +6 -0
- data/opals/opal/spec/core/true/xor_spec.rb +10 -0
- data/opals/opal/spec/fixtures/super.rb +70 -0
- data/opals/opal/spec/language/____temp_remove_this.rb +12 -0
- data/opals/opal/spec/language/and_spec.rb +62 -0
- data/opals/opal/spec/language/array_spec.rb +52 -0
- data/opals/opal/spec/language/block_spec.rb +18 -0
- data/opals/opal/spec/language/break_spec.rb +36 -0
- data/opals/opal/spec/language/case_spec.rb +103 -0
- data/opals/opal/spec/language/def_spec.rb +11 -0
- data/opals/opal/spec/language/eigenclass_spec.rb +60 -0
- data/opals/opal/spec/language/hash_spec.rb +29 -0
- data/opals/opal/spec/language/if_spec.rb +54 -0
- data/opals/opal/spec/language/loop_spec.rb +11 -0
- data/opals/opal/spec/language/metaclass_spec.rb +21 -0
- data/opals/opal/spec/language/method_spec.rb +64 -0
- data/opals/opal/spec/language/next_spec.rb +25 -0
- data/opals/opal/spec/language/or_spec.rb +34 -0
- data/opals/opal/spec/language/redo_spec.rb +24 -0
- data/opals/opal/spec/language/rescue_spec.rb +20 -0
- data/opals/opal/spec/language/return_spec.rb +47 -0
- data/opals/opal/spec/language/string_spec.rb +25 -0
- data/opals/opal/spec/language/super_spec.rb +26 -0
- data/opals/opal/spec/language/until_spec.rb +157 -0
- data/opals/opal/spec/language/while_spec.rb +163 -0
- data/opals/opal/spec/spec_helper.rb +5 -0
- data/opals/runtime/Opalfile +68 -0
- data/opals/runtime/README.md +12 -0
- data/opals/runtime/docs/debugging.md +51 -0
- data/opals/runtime/lib/array.rb +1516 -0
- data/opals/runtime/lib/basic_object.rb +49 -0
- data/opals/runtime/lib/class.rb +54 -0
- data/opals/runtime/lib/dir.rb +36 -0
- data/opals/runtime/lib/error.rb +49 -0
- data/opals/runtime/lib/false_class.rb +52 -0
- data/opals/runtime/lib/file.rb +79 -0
- data/opals/runtime/lib/hash.rb +791 -0
- data/opals/runtime/lib/io.rb +39 -0
- data/opals/runtime/lib/kernel.rb +288 -0
- data/opals/runtime/lib/match_data.rb +36 -0
- data/opals/runtime/lib/module.rb +109 -0
- data/opals/runtime/lib/nil_class.rb +69 -0
- data/opals/runtime/lib/number.rb +398 -0
- data/opals/runtime/lib/proc.rb +77 -0
- data/opals/runtime/lib/range.rb +63 -0
- data/opals/runtime/lib/regexp.rb +111 -0
- data/opals/runtime/lib/ruby.rb +30 -0
- data/opals/runtime/lib/string.rb +328 -0
- data/opals/runtime/lib/symbol.rb +40 -0
- data/opals/runtime/lib/top_self.rb +33 -0
- data/opals/runtime/lib/true_class.rb +45 -0
- data/opals/runtime/runtime/browser.js +287 -0
- data/opals/runtime/runtime/debug.js +182 -0
- data/opals/runtime/runtime/opal.js +1010 -0
- data/opals/runtime/runtime/post_opal.js +1 -0
- data/opals/runtime/runtime/pre_opal.js +2 -0
- data/opals/runtime/runtime/server_side.js +50 -0
- data/opals/spec/LICENSE.txt +26 -0
- data/opals/spec/Opalfile +5 -0
- data/opals/spec/bin/spec.rb +43 -0
- data/opals/spec/lib/spec.rb +33 -0
- data/opals/spec/lib/spec/dsl.rb +41 -0
- data/opals/spec/lib/spec/example.rb +35 -0
- data/opals/spec/lib/spec/example/before_and_after_hooks.rb +81 -0
- data/opals/spec/lib/spec/example/errors.rb +42 -0
- data/opals/spec/lib/spec/example/example_group.rb +37 -0
- data/opals/spec/lib/spec/example/example_group_factory.rb +43 -0
- data/opals/spec/lib/spec/example/example_group_hierarchy.rb +45 -0
- data/opals/spec/lib/spec/example/example_group_methods.rb +142 -0
- data/opals/spec/lib/spec/example/example_group_proxy.rb +41 -0
- data/opals/spec/lib/spec/example/example_methods.rb +73 -0
- data/opals/spec/lib/spec/example/example_proxy.rb +48 -0
- data/opals/spec/lib/spec/expectations.rb +46 -0
- data/opals/spec/lib/spec/expectations/errors.rb +35 -0
- data/opals/spec/lib/spec/expectations/fail_with.rb +37 -0
- data/opals/spec/lib/spec/expectations/handler.rb +48 -0
- data/opals/spec/lib/spec/matchers.rb +50 -0
- data/opals/spec/lib/spec/matchers/be.rb +26 -0
- data/opals/spec/lib/spec/matchers/generated_descriptions.rb +47 -0
- data/opals/spec/lib/spec/matchers/operator_matcher.rb +66 -0
- data/opals/spec/lib/spec/runner.rb +48 -0
- data/opals/spec/lib/spec/runner/example_group_runner.rb +71 -0
- data/opals/spec/lib/spec/runner/formatter/html_formatter.rb +100 -0
- data/opals/spec/lib/spec/runner/formatter/terminal_formatter.rb +82 -0
- data/opals/spec/lib/spec/runner/options.rb +63 -0
- data/opals/spec/lib/spec/runner/reporter.rb +123 -0
- data/opals/spec/resources/index.html +25 -0
- data/opals/spec/resources/spec.css +132 -0
- data/spec/cherry_kit/iseq_spec.rb +38 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/vienna_spec.rb +7 -0
- data/yard/index.html +43 -0
- data/yard/style.css +765 -0
- metadata +312 -49
- data/docs/jarv.rdoc +0 -27
- data/runtime/array.js +0 -153
- data/runtime/class.js +0 -469
- data/runtime/compar.js +0 -73
- data/runtime/dir.js +0 -115
- data/runtime/enum.js +0 -74
- data/runtime/file.js +0 -165
- data/runtime/gem.js +0 -241
- data/runtime/hash.js +0 -181
- data/runtime/load.js +0 -251
- data/runtime/module.js +0 -98
- data/runtime/number.js +0 -148
- data/runtime/object.js +0 -522
- data/runtime/opal.js +0 -200
- data/runtime/parse.js +0 -2218
- data/runtime/range.js +0 -56
- data/runtime/re.js +0 -91
- data/runtime/string.js +0 -199
- data/runtime/variable.js +0 -184
- data/runtime/vm.js +0 -1150
- data/tasks/build.rb +0 -16
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#
|
|
2
|
+
# object_controller.rb
|
|
3
|
+
# vienna
|
|
4
|
+
#
|
|
5
|
+
# Created by Adam Beynon.
|
|
6
|
+
# Copyright 2010 Adam Beynon.
|
|
7
|
+
#
|
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
# furnished to do so, subject to the following conditions:
|
|
14
|
+
#
|
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
|
16
|
+
# all copies or substantial portions of the Software.
|
|
17
|
+
#
|
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
# THE SOFTWARE.
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
require 'foundation/controllers/controller'
|
|
28
|
+
|
|
29
|
+
module CherryKit
|
|
30
|
+
|
|
31
|
+
class ObjectController < Controller
|
|
32
|
+
|
|
33
|
+
expose_binding :editable
|
|
34
|
+
|
|
35
|
+
expose_binding :content_object
|
|
36
|
+
|
|
37
|
+
keys_affecting :can_add => [:editable]
|
|
38
|
+
|
|
39
|
+
keys_affecting :can_insert => [:editable]
|
|
40
|
+
|
|
41
|
+
keys_affecting :can_remove => [:editable, :selection]
|
|
42
|
+
|
|
43
|
+
keys_affecting :content_object => [:content]
|
|
44
|
+
|
|
45
|
+
attr_reader :content
|
|
46
|
+
|
|
47
|
+
attr_accessor :selection
|
|
48
|
+
|
|
49
|
+
attr_accessor :object_class
|
|
50
|
+
|
|
51
|
+
def initialize(content)
|
|
52
|
+
super
|
|
53
|
+
self.content = `#{content} || #{nil}`
|
|
54
|
+
self.editable = true
|
|
55
|
+
self.object_class = Hash
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def content=(content)
|
|
59
|
+
# puts "setting content to #{content}"
|
|
60
|
+
unless @content == content
|
|
61
|
+
will_change_attribute :content_object
|
|
62
|
+
_selection_will_change
|
|
63
|
+
@content = content
|
|
64
|
+
did_change_attribute :content_object
|
|
65
|
+
_selection_did_change
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
content
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def _selection_will_change
|
|
72
|
+
will_change_attribute :selection
|
|
73
|
+
@selection.controller_will_change if @selection
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def _selection_did_change
|
|
77
|
+
@selection = ControllerSelectionProxy.new(self) unless @selection
|
|
78
|
+
@selection.controller_did_change
|
|
79
|
+
did_change_attribute :selection
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def selected_objects
|
|
83
|
+
[@content]
|
|
84
|
+
# []
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Create a new instance of the object_class
|
|
88
|
+
#
|
|
89
|
+
def new_object
|
|
90
|
+
object_class.new
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Add the given object
|
|
94
|
+
#
|
|
95
|
+
def add_object(object)
|
|
96
|
+
self.content = object
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# An action to add a new object. This simply adds a new instance of our
|
|
100
|
+
# object class.
|
|
101
|
+
#
|
|
102
|
+
def add(sender)
|
|
103
|
+
add_object new_object
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# True/false whether this object controller is able to add an object. This
|
|
107
|
+
# is determined by whether the receiver is editable or not
|
|
108
|
+
#
|
|
109
|
+
# @returns {true|false}
|
|
110
|
+
#
|
|
111
|
+
def can_add?
|
|
112
|
+
editable?
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def can_remove?
|
|
116
|
+
editable? && selected_objects.length > 0
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def editable?
|
|
120
|
+
@editable
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def editable=(editable)
|
|
124
|
+
@editable = editable
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def automatically_prepares_content?
|
|
128
|
+
@automatically_prepares_content
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
attr_writer :automatically_prepares_content
|
|
132
|
+
|
|
133
|
+
# def observe
|
|
134
|
+
|
|
135
|
+
attr_reader :_observed_keys
|
|
136
|
+
|
|
137
|
+
def _content_object
|
|
138
|
+
content
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def _content_object=(value)
|
|
142
|
+
self.content = value
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#
|
|
2
|
+
# view.rb
|
|
3
|
+
# vienna
|
|
4
|
+
#
|
|
5
|
+
# Created by Adam Beynon.
|
|
6
|
+
# Copyright 2010 Adam Beynon.
|
|
7
|
+
#
|
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
# furnished to do so, subject to the following conditions:
|
|
14
|
+
#
|
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
|
16
|
+
# all copies or substantial portions of the Software.
|
|
17
|
+
#
|
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
# THE SOFTWARE.
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
require 'foundation/core/responder'
|
|
28
|
+
|
|
29
|
+
module CherryKit
|
|
30
|
+
|
|
31
|
+
class ViewController
|
|
32
|
+
|
|
33
|
+
attr_reader :first_name
|
|
34
|
+
|
|
35
|
+
def initialize
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
#
|
|
2
|
+
# application.rb
|
|
3
|
+
# vienna
|
|
4
|
+
#
|
|
5
|
+
# Created by Adam Beynon.
|
|
6
|
+
# Copyright 2010 Adam Beynon.
|
|
7
|
+
#
|
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
# in the Software without restriction, including without limitation the rights
|
|
11
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
# furnished to do so, subject to the following conditions:
|
|
14
|
+
#
|
|
15
|
+
# The above copyright notice and this permission notice shall be included in
|
|
16
|
+
# all copies or substantial portions of the Software.
|
|
17
|
+
#
|
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
# THE SOFTWARE.
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
require 'foundation/core/responder'
|
|
28
|
+
|
|
29
|
+
module CherryKit
|
|
30
|
+
|
|
31
|
+
# Main Application class to control the lifetime and control flow of events
|
|
32
|
+
# through a cherry kit application. Custom behaviour can be setup through
|
|
33
|
+
# the application delegate, which by default is the custom AppController
|
|
34
|
+
# class.
|
|
35
|
+
#
|
|
36
|
+
# Notifications
|
|
37
|
+
# -------------
|
|
38
|
+
#
|
|
39
|
+
# On setting the delegate, the delegate is automatically registered to receive
|
|
40
|
+
# all of the following notifications on the presumtion that it has a method
|
|
41
|
+
# named the same as the notification name. Any methods that are not
|
|
42
|
+
# implemented will simply not receive the relevant notification. All
|
|
43
|
+
# notifications and methods are optional, but application_did_finish_launching
|
|
44
|
+
# is highly recomended as it is the best/required place to setup the
|
|
45
|
+
# application GUI.
|
|
46
|
+
#
|
|
47
|
+
# :application_will_finish_launching - sent when the application is nearly
|
|
48
|
+
# ready to run, but before any global events are registered. This is a
|
|
49
|
+
# suitable place to perform any additional tasks before the DOM is likely to
|
|
50
|
+
# be ready.
|
|
51
|
+
#
|
|
52
|
+
# :application_did_finish_launching - sent once the DOM has been setup and all
|
|
53
|
+
# relevant events are in place. This is a suitable time to load the main
|
|
54
|
+
# interface for the application by loading some windows, or using the
|
|
55
|
+
# Builder class and its related methods.
|
|
56
|
+
#
|
|
57
|
+
class Application < Responder
|
|
58
|
+
|
|
59
|
+
# The application delegate.
|
|
60
|
+
#
|
|
61
|
+
attr_reader :delegate
|
|
62
|
+
|
|
63
|
+
def initialize
|
|
64
|
+
# an array of all our windows
|
|
65
|
+
@windows = []
|
|
66
|
+
# hash of our touch identifiers to the touches themselves.
|
|
67
|
+
@touches = {}
|
|
68
|
+
# hash of views to an array of touch identifiers
|
|
69
|
+
@touches_for_views = {}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Register the window for the application
|
|
73
|
+
def register_window(window)
|
|
74
|
+
@windows << window
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Set the application delegate. This method will register the delegate for
|
|
78
|
+
# all notification messages that it has a defined method for.
|
|
79
|
+
#
|
|
80
|
+
# @param {Object} delegate to set
|
|
81
|
+
# @returns delegate
|
|
82
|
+
#
|
|
83
|
+
def delegate=(delegate)
|
|
84
|
+
@delegate = delegate
|
|
85
|
+
|
|
86
|
+
center = NotificationCenter.default_center
|
|
87
|
+
|
|
88
|
+
notifications = [
|
|
89
|
+
:application_will_finish_launching,
|
|
90
|
+
:application_did_finish_launching
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
notifications.each do |notification|
|
|
94
|
+
if delegate.respond_to? notification
|
|
95
|
+
center.add_observer delegate, notification, notification, self
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
delegate
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Run the application.
|
|
103
|
+
def run
|
|
104
|
+
RunLoop.run do
|
|
105
|
+
# body class names for css etc
|
|
106
|
+
setup_body_class_names
|
|
107
|
+
# global application
|
|
108
|
+
Object.const_set('CKApp', self)
|
|
109
|
+
# our main application window that we create ourselves and give (for
|
|
110
|
+
# free to AppController)
|
|
111
|
+
window = CherryKit::Window.build({})
|
|
112
|
+
window.show
|
|
113
|
+
@delegate.window = window
|
|
114
|
+
# puts "need to add window to #{@delegate}"
|
|
115
|
+
# initial notification that we will finish launching (before events)
|
|
116
|
+
notify :application_will_finish_launching
|
|
117
|
+
# setup/create all event handlers
|
|
118
|
+
setup_event_handlers
|
|
119
|
+
# we can post our did finish launching once we have all our events setup
|
|
120
|
+
notify :application_did_finish_launching
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def setup_body_class_names
|
|
125
|
+
body = Browser::Element.body
|
|
126
|
+
if Browser.safari?
|
|
127
|
+
body.class_name = 'safari'
|
|
128
|
+
elsif Browser.opera?
|
|
129
|
+
body.class_name = 'opera'
|
|
130
|
+
elsif Browser.msie?
|
|
131
|
+
# also set ie7, ie6, ie8 respectively?
|
|
132
|
+
body.class_name = 'msie'
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def setup_event_handlers
|
|
137
|
+
# touch based events..
|
|
138
|
+
listen_for Browser.document, :touchstart, :touchmove, :touchend, :touchcancel
|
|
139
|
+
# standard mouse events
|
|
140
|
+
listen_for Browser.document, :mousedown, :mouseup, :mousemove
|
|
141
|
+
|
|
142
|
+
listen_for Browser.document, :keydown, :keyup, :keypress
|
|
143
|
+
|
|
144
|
+
# browser window resizing
|
|
145
|
+
listen_for Browser.window, :resize
|
|
146
|
+
|
|
147
|
+
# browser dependant focus/blur events
|
|
148
|
+
if Browser.msie?
|
|
149
|
+
# event_handler Browser.document, :focusin
|
|
150
|
+
# event_handler Browser.document, :focusout
|
|
151
|
+
else
|
|
152
|
+
# event_handler Browser.window, :focus
|
|
153
|
+
# event_handler Browser.window, :blur
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def listen_for(target, *events)
|
|
158
|
+
events.each do |event|
|
|
159
|
+
Browser::Event.listen target, event, __send__("on_#{event}")
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# Dispatch the event
|
|
164
|
+
#
|
|
165
|
+
# @param {CherryKit::Event} event to send
|
|
166
|
+
# @returns nil
|
|
167
|
+
#
|
|
168
|
+
def send_event(event)
|
|
169
|
+
# keep track of our current event
|
|
170
|
+
@current_event = event
|
|
171
|
+
# if we have an event handler registered, delegate events to that
|
|
172
|
+
if @event_handler
|
|
173
|
+
event.view = @event_handler_view
|
|
174
|
+
RunLoop.run do
|
|
175
|
+
`#{@event_handler}.apply(#{@event_handler}.__self__, [#{event}]);`
|
|
176
|
+
end
|
|
177
|
+
else
|
|
178
|
+
# send event within a runloop block so that all action calls etc are
|
|
179
|
+
# caught, as well as view display requests, so we can run them on
|
|
180
|
+
# completion of sending the event
|
|
181
|
+
RunLoop.run do
|
|
182
|
+
# puts "============= sending event on within runloop!"
|
|
183
|
+
# puts event.type
|
|
184
|
+
# return
|
|
185
|
+
# # `console.log(#{event});`
|
|
186
|
+
# puts "view for event is: #{event.view}"
|
|
187
|
+
# puts "window for event is: #{event.window}"
|
|
188
|
+
res = event.window.send_event event
|
|
189
|
+
# puts "res is #{res}"
|
|
190
|
+
res
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# Set a block delegate for dealing with all events matching the given event
|
|
196
|
+
# array. Any other event will simply be ignored until the removal of this
|
|
197
|
+
# block.
|
|
198
|
+
#
|
|
199
|
+
# Note
|
|
200
|
+
# ----
|
|
201
|
+
# This method will also pass the current event to the block, so in the
|
|
202
|
+
# following example, the mouse_down event will be passed as well.
|
|
203
|
+
#
|
|
204
|
+
# Usage
|
|
205
|
+
# -----
|
|
206
|
+
#
|
|
207
|
+
# app.handle_events([:mouse_down, :mouse_dragged]) do |event|
|
|
208
|
+
# puts "got new event #{event}"
|
|
209
|
+
# end
|
|
210
|
+
#
|
|
211
|
+
# @param {Proc} block
|
|
212
|
+
#
|
|
213
|
+
def handle_events(events, &block)
|
|
214
|
+
@event_handler = block
|
|
215
|
+
@event_handler_events = events
|
|
216
|
+
@event_handler_view = @current_event.view
|
|
217
|
+
# resend current event
|
|
218
|
+
`#{@event_handler}.apply(#{@event_handler}.__self__, [#{@current_event}]);`
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# Discard event capture.
|
|
222
|
+
#
|
|
223
|
+
def finish_handling_events
|
|
224
|
+
@event_handler = nil
|
|
225
|
+
@event_handler_events = nil
|
|
226
|
+
@event_handler_view = nil
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# Get the array for the view, or make it if it does not exist
|
|
230
|
+
def touches_for_view(view)
|
|
231
|
+
if @touches_for_views[view]
|
|
232
|
+
@touches_for_views[view]
|
|
233
|
+
else
|
|
234
|
+
@touches_for_views[view] = []
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def setup_touch_began(touch, event)
|
|
239
|
+
touch_hierarchy = []
|
|
240
|
+
view = touch.view
|
|
241
|
+
# get all views in hierarchy
|
|
242
|
+
`while(#{view}.r) {
|
|
243
|
+
#{touch_hierarchy}.unshift(#{view});
|
|
244
|
+
#{view} = #{view.superview};
|
|
245
|
+
}`
|
|
246
|
+
|
|
247
|
+
capturing_view = nil
|
|
248
|
+
to_try = nil
|
|
249
|
+
|
|
250
|
+
# find first view that will capture_touches? .. if any
|
|
251
|
+
`for (var i = 0; i < #{touch_hierarchy}.length; i++) {
|
|
252
|
+
#{to_try} = #{touch_hierarchy}[i];
|
|
253
|
+
if (#{to_try.capture_touches?}.r) {
|
|
254
|
+
#{capturing_view} = #{to_try};
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
}`
|
|
258
|
+
|
|
259
|
+
if capturing_view
|
|
260
|
+
touch.view = capturing_view
|
|
261
|
+
else
|
|
262
|
+
touch.view = event.view
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# puts "touch hierarchy is #{touch_hierarchy.inspect}"
|
|
266
|
+
# puts "capturing view is #{capturing_view}"
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# When the user touches their finger on the document.
|
|
270
|
+
def on_touchstart
|
|
271
|
+
proc do |event|
|
|
272
|
+
RunLoop.run do
|
|
273
|
+
# puts "touchstart!"
|
|
274
|
+
touches = event.changed_touches
|
|
275
|
+
touches.each do |touch|
|
|
276
|
+
# keep track of this touch (with identifier)
|
|
277
|
+
@touches[touch.identifier] = touch
|
|
278
|
+
# assign the event for the touch
|
|
279
|
+
touch.event = event
|
|
280
|
+
# touch.view = event.view
|
|
281
|
+
# puts "touch began #{touch.identifier}"
|
|
282
|
+
setup_touch_began touch, event
|
|
283
|
+
# we have our right view, so make sure that we can send events to it
|
|
284
|
+
# i.e. is it multi touch enabled? cannot send more than one touch
|
|
285
|
+
# to non multi touch views
|
|
286
|
+
view = touch.view
|
|
287
|
+
view_touches = touches_for_view(view)
|
|
288
|
+
|
|
289
|
+
if view.multiple_touch_enabled?
|
|
290
|
+
puts "can send event!"
|
|
291
|
+
view_touches << touch.identifier
|
|
292
|
+
touch.view.touches_began(touches, event)
|
|
293
|
+
else
|
|
294
|
+
# puts "#{view} is not multi touch friendly"
|
|
295
|
+
if view_touches.length > 0
|
|
296
|
+
# puts "need to drop touch: multitouch not enabled for view"
|
|
297
|
+
puts "touch_start: #{touch.identifier} being dropped"
|
|
298
|
+
else
|
|
299
|
+
view_touches << touch.identifier
|
|
300
|
+
puts "touch_start: #{touch.identifier} sending!"
|
|
301
|
+
touch.view.touches_began(touches, event)
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
# puts event.changed_touches
|
|
307
|
+
# puts event.view
|
|
308
|
+
|
|
309
|
+
false
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def on_touchend
|
|
315
|
+
proc do |event|
|
|
316
|
+
|
|
317
|
+
RunLoop.run do
|
|
318
|
+
touches = event.changed_touches
|
|
319
|
+
touches.each do |touch|
|
|
320
|
+
entry = @touches[touch.identifier]
|
|
321
|
+
|
|
322
|
+
if @touches_for_views[entry.view].include? touch.identifier
|
|
323
|
+
puts "sending touchend for #{entry.identifier}"
|
|
324
|
+
entry.event = event
|
|
325
|
+
entry.view.touches_ended(touches, event)
|
|
326
|
+
@touches_for_views[entry.view].delete touch.identifier
|
|
327
|
+
else
|
|
328
|
+
# drop event otherwise
|
|
329
|
+
# puts "dropping touch end for #{entry.identifier}"
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
false
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def on_touchmove
|
|
339
|
+
proc do |event|
|
|
340
|
+
RunLoop.run do
|
|
341
|
+
# hash of views => touches for that view
|
|
342
|
+
view_touches = {}
|
|
343
|
+
touches = event.changed_touches
|
|
344
|
+
touches.each do |touch|
|
|
345
|
+
entry = @touches[touch.identifier]
|
|
346
|
+
|
|
347
|
+
unless entry
|
|
348
|
+
raise "Application: touchmove: unknown touch #{touch.identifier}"
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
if @touches_for_views[entry.view].include? touch.identifier
|
|
352
|
+
entry.event = event
|
|
353
|
+
|
|
354
|
+
view_array = view_touches[entry.view]
|
|
355
|
+
|
|
356
|
+
unless view_array
|
|
357
|
+
view_array = view_touches[entry.view] = []
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
view_array << touch
|
|
361
|
+
|
|
362
|
+
entry.view.touches_moved(touches, event)
|
|
363
|
+
else
|
|
364
|
+
# puts "dropping move event for touch #{touch.identifier}"
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
end
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
false
|
|
371
|
+
end
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def on_touchcancel
|
|
375
|
+
proc do |event|
|
|
376
|
+
puts "touchcancel!"
|
|
377
|
+
true
|
|
378
|
+
end
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
# Handles the window's 'resize' event. This method simply posts out
|
|
382
|
+
# notifications to alert receivers that the browser window, i.e. screen
|
|
383
|
+
# space is being adjusted. By default, every window will listen for these
|
|
384
|
+
# notifications so that they can resize and /or move to suit
|
|
385
|
+
#
|
|
386
|
+
# @param {Browser::Event} event from browser
|
|
387
|
+
# @returns self
|
|
388
|
+
#
|
|
389
|
+
def on_resize
|
|
390
|
+
proc do |event|
|
|
391
|
+
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def on_keydown
|
|
396
|
+
proc do |event|
|
|
397
|
+
event.type = :key_down
|
|
398
|
+
# puts "sending keydown event for #{event.key_code} for #{event.key}"
|
|
399
|
+
res = send_event event
|
|
400
|
+
# puts "on_keydown handler result is #{res}"
|
|
401
|
+
res
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
def on_keyup
|
|
406
|
+
proc do |event|
|
|
407
|
+
event.type = :key_up
|
|
408
|
+
# puts "sending keyup event for #{event.key_code} for #{event.key}"
|
|
409
|
+
send_event event
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
def on_keypress
|
|
414
|
+
proc do |event|
|
|
415
|
+
event.type = :key_down
|
|
416
|
+
# puts "sending keypress event for #{event.key_code} for #{event.key}"
|
|
417
|
+
return true
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
def on_mousemove
|
|
422
|
+
proc do |event|
|
|
423
|
+
# must make ruby friendly name - should check if mouse_dragged
|
|
424
|
+
event.type = :mouse_moved
|
|
425
|
+
# puts "mouse moved!"
|
|
426
|
+
send_event event
|
|
427
|
+
|
|
428
|
+
true
|
|
429
|
+
end
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
# Handles raw events from the browser for mousedown
|
|
433
|
+
#
|
|
434
|
+
# @param [Browser::Event] event received
|
|
435
|
+
# @returns self
|
|
436
|
+
#
|
|
437
|
+
def on_mousedown
|
|
438
|
+
proc do |event|
|
|
439
|
+
# begin
|
|
440
|
+
# first we rename the event to our ruby friendly name
|
|
441
|
+
event.type = :mouse_down
|
|
442
|
+
@mouse_down_view = view = event.view
|
|
443
|
+
window = view.window
|
|
444
|
+
# get current first responder
|
|
445
|
+
first_responder = window.first_responder
|
|
446
|
+
# make the view the first responder (if it accepts it)
|
|
447
|
+
if view != first_responder && view.accepts_first_responder?
|
|
448
|
+
window.make_first_responder? view
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
send_event event
|
|
452
|
+
# rescue Exception => e
|
|
453
|
+
# puts "exception occured within Application#on_mousedown"
|
|
454
|
+
# raise e
|
|
455
|
+
# end
|
|
456
|
+
|
|
457
|
+
true
|
|
458
|
+
end
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
# Handles raw mouseup events from browser
|
|
462
|
+
#
|
|
463
|
+
# @para, [Browser::Event] event received
|
|
464
|
+
# @returns self
|
|
465
|
+
#
|
|
466
|
+
def on_mouseup
|
|
467
|
+
proc do |event|
|
|
468
|
+
event.type = :mouse_up
|
|
469
|
+
send_event event
|
|
470
|
+
|
|
471
|
+
true
|
|
472
|
+
end
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
end
|
|
476
|
+
end
|