summaryrefslogtreecommitdiff
path: root/doc/classes/PopUpMenu.src/M000042.html
blob: cf301b20a57ac1c5c51fe7c64e68f4d0ea1271b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>change_node (PopUpMenu)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/json/editor.rb, line 265</span>
      <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">change_node</span>(<span class="ruby-identifier">item</span>)
        <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">current</span> = <span class="ruby-identifier">selection</span>.<span class="ruby-identifier">selected</span>
          <span class="ruby-identifier">parent</span> = <span class="ruby-identifier">current</span>.<span class="ruby-identifier">parent</span>
          <span class="ruby-identifier">old_type</span>, <span class="ruby-identifier">old_content</span> = <span class="ruby-identifier">current</span>.<span class="ruby-identifier">type</span>, <span class="ruby-identifier">current</span>.<span class="ruby-identifier">content</span>
          <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ALL_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">old_type</span>)
            <span class="ruby-ivar">@clipboard_data</span> = <span class="ruby-constant">Editor</span>.<span class="ruby-identifier">model2data</span>(<span class="ruby-identifier">current</span>)
            <span class="ruby-identifier">type</span>, <span class="ruby-identifier">content</span> = <span class="ruby-identifier">ask_for_element</span>(<span class="ruby-identifier">parent</span>, <span class="ruby-identifier">current</span>.<span class="ruby-identifier">type</span>,
              <span class="ruby-identifier">current</span>.<span class="ruby-identifier">content</span>)
            <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">type</span>
              <span class="ruby-identifier">current</span>.<span class="ruby-identifier">type</span>, <span class="ruby-identifier">current</span>.<span class="ruby-identifier">content</span> = <span class="ruby-identifier">type</span>, <span class="ruby-identifier">content</span>
              <span class="ruby-identifier">current</span>.<span class="ruby-identifier">remove_subtree</span>(<span class="ruby-identifier">model</span>)
              <span class="ruby-identifier">toplevel</span>.<span class="ruby-identifier">display_status</span>(<span class="ruby-value str">&quot;Changed a node in tree.&quot;</span>)
              <span class="ruby-identifier">window</span>.<span class="ruby-identifier">change</span>
            <span class="ruby-keyword kw">end</span>
          <span class="ruby-keyword kw">else</span>
            <span class="ruby-identifier">toplevel</span>.<span class="ruby-identifier">display_status</span>(
              <span class="ruby-node">&quot;Cannot change node of type #{old_type} in tree!&quot;</span>)
          <span class="ruby-keyword kw">end</span>
        <span class="ruby-keyword kw">end</span>
      <span class="ruby-keyword kw">end</span></pre>
</body>
</html>