Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 134 lines (97 sloc) 3.532 kb
6454894 @ashbb added sample 46 and modified built-in constant
authored
1 Open a new app window
2 ---------------------
3
4 We can use **window** method to open a new app window.
5
6 # sample46.rb
7 Shoes.app :title => 'parent', :width => 300, :height => 200 do
8 def open_new_window
9 window :title => 'child', :width => 200, :height => 200 do
10 button('parent'){owner.hello green}
11 button('child'){owner.hello green, self}
12 end
13 end
14
15 def hello color, win = nil
16 win ||= self
17 @n ||= 0
18 @n += 1
19 win.para strong("#{win}--#{@n}\n"), :stroke => color
20 end
21
22 button('parent'){hello red}
23 button('child'){hello red, @w}
24 para link('open a new window'){@w = open_new_window}
25 end
26
27 **sample46.png**
28
2f0c4ac @ashbb deleted patches
authored
29 ![sample46.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample46.png)
6454894 @ashbb added sample 46 and modified built-in constant
authored
30
31 This screenshot shows the following.
32 + open parent window.
33 + in parent window, click parent button, output is --1
34 + in parent window, click child button, output is --2
35 + click 'open a new window' link, open a child window.
36 + in child window, click parent button, output is --3
37 + in child window, click child button, output is --4
38 + in parent window, click parent button, output is --5
39 + in parent window, click child button, output is --6
40
61b9bb4 @ashbb added a new sample 48
authored
41
42
43 **Another example.** <br>
44 We can use **Shoes.app** method to open a new app window.
45
46 # sample48.rb
47 @blk = class Trip < Shoes
48 url "/", :index
49 url "/japan", :japan
50 url "/india", :india
51 url "/tokyo", :tokyo
52 url "/pune", :pune
53
54 @@win = 0
55
56 def index
57 case @@win
58 when 0
59 background coral
60 para strong link("Go to Japan.", :click => "/japan")
61 para strong link("Go to India.", :click => "/india")
62 when 1
63 background crimson
64 para strong link("Go to Tokyo.", :click => "/tokyo")
65 when 2
66 background darkorange
67 para strong link("Go to Pune.", :click => "/pune")
68 else
69 end
70 end
71
72 def japan
73 @@win = 1
74 Shoes.app :title => "Japan", :width => 200, :height => 100, &@blk
75 @@win = 0
76 visit "/"
77 end
78
79 def india
80 @@win = 2
81 Shoes.app :title => "India", :width => 200, :height => 100, &@blk
82 @@win = 0
83 visit "/"
84 end
85
86 def tokyo
87 background gold
88 para strong "Welcome to Tokyo!"
89 end
90
91 def pune
92 background darksalmon
93 para strong "Welcome to Pune!"
94 end
95 end
96
97 Shoes.app :title => "World Trip", :width => 200, :height => 100, &@blk
98
9ab0633 @ashbb fixed a bug and added some note about some bugs
authored
99
100 __Note:__ <br>
101 Code Highlighter has a bug. It may replace __&@__ to __&;@__ in the code falsely. :( <br>
102 So, please use sample48.rb under src directory instead of above code. <br>
103
104
61b9bb4 @ashbb added a new sample 48
authored
105 **sample48.png**
106
2f0c4ac @ashbb deleted patches
authored
107 ![sample48.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample48.png)
61b9bb4 @ashbb added a new sample 48
authored
108
109 This screenshot shows the following.
110 + open first window: title is World Trip
111 + in first window, click 'Go to Japan', open second window: title is Japan
112 + in first window, click 'Go to India', open third window: title is India
113 + in second window, click 'Go to Tokyo', chang Shoes-URL on the same window, then shows the message "Welcome to Tokyo!"
114
115
116 The original idea was discussed in the Shoes ML. <br>
117 [links in ur windoze](http://www.mail-archive.com/shoes@code.whytheluckystiff.net/msg02404.html)
8a32357 @ashbb Confirmed 00521-00532. Finished 67 / 132 samples.
authored
118
119
120 Policeman
121 ---------
122
123 The sample46.rb worked with Shoes-0.r1263. The behavior was the same as Raisins. But showed slightly different messages like this:
124
89ec419 @ashbb Confirmed 00521-00532. Finished 67 / 132 samples.
authored
125 **sample46-1.png**
126
127 ![sample46-1.png](http://github.com/ashbb/shoes_tutorial_html/raw/master/images/sample46-1.png)
8a32357 @ashbb Confirmed 00521-00532. Finished 67 / 132 samples.
authored
128
129
130
131 The sample48.rb worked well with Shoes-0.r1263
132
133
Something went wrong with that request. Please try again.