summaryrefslogtreecommitdiffstats
path: root/qtbrowserplugin/examples/trivial/scripting.qdoc
blob: 5c235c6383ddfa35a4fd23df28b1391142c10be5 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
// SPDX-License-Identifier: BSD-3-Clause

/*! \page qtbrowserplugin-example-scripting.html

  \title Scripting Example

  This example demonstrates the combination of Javascript and a
  trivial plugin, and the use of a plugin in combination with a form.

  If the browser supports scripting plugins, and everything is set up
  correctly, the plugin below should react to mouse clicks and drags
  by changing its text. The \c About... button should pop up an
  \c{About Qt} dialog. The second plugin instance, below the
  horizontal line, should display the word \c QtBrowserPlugin, and
  pressing the \c Go! button should navigate the browser to a search
  for this word at google.com.

  \raw HTML 
  <object id="ScriptableObject" TYPE=trivial/very WIDTH=200 HEIGHT=100 text="Very Scriptable!"> </object>

  <script language=JavaScript>
  var ScriptableObject = document.getElementById('ScriptableObject');
  ScriptableObject.text = 'This is some text'

  var oldText
  ScriptableObject.mouseDown = function()
  {
    oldText = ScriptableObject.text
    ScriptableObject.text = 'Mouse Down'
  }

  ScriptableObject.mouseMove = function(x, y)
  {
    ScriptableObject.text = 'Mouse at ' + x + ',' + y
  }

  ScriptableObject.mouseUp = function()
  {
    ScriptableObject.text = oldText
  }
  </script>

  <!-- Special hookup code required for Internet Explorer -->
  <!--[if IE]>
  <script language=JScript>
  function ScriptableObject::mouseDown() { ScriptableObject.mouseDown() }
  function ScriptableObject::mouseMove(x, y) { ScriptableObject.mouseMove(x, y) }
  function ScriptableObject::mouseUp() { ScriptableObject.mouseUp() }
  </script>
  <![endif]-->

  <form>
  <input type="button" value="About..." OnClick="ScriptableObject.about();"/>
  </form>

  <hr>
  <form method="GET" action="http://www.google.com/search">
  Search at Google:
  <object id="SearchableText" name="q" type=trivial/very width=150 height=40 text="QtBrowserPlugin"></object>
  <input type="submit" value="Go!">
  </form>
  \endraw

  Implementation:

  \quotefile trivial/trivial.cpp
*/