Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
Fixed Issue #12
Browse files Browse the repository at this point in the history
Fixed Issue #13
  • Loading branch information
gossi committed Sep 5, 2010
1 parent 5a7a4e0 commit 00f1efa
Show file tree
Hide file tree
Showing 17 changed files with 762 additions and 158 deletions.
107 changes: 107 additions & 0 deletions dev/widgets/listener.html
@@ -0,0 +1,107 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>control listener (dev)</title>
<link rel="stylesheet" href="../../css/themes/sand/sand.css" type="text/css"/>
<script type="text/javascript" src="../../src/gara.js"></script>
<script type="text/javascript">
var list, text, tree,
controlListener = {
mouseEnter : function(e) {
console.log("Mouse Entered on " + e.widget);
},

mouseExit : function(e) {
console.log("Mouse Exited on " + e.widget);
},

mouseHover : function(e) {
//console.log("Mouse Hovered on " + e.widget);
},

mouseMove : function(e) {
console.log("Mouse Moved");
},

mouseScrolled : function(e) {
console.log("Mouse Scrolled " + e.detail);
},

controlResized : function(e) {
console.log("Control Resized");
},

controlMoved : function(e) {
console.log("Control Moved");
}
},
modifyListener = {
modifyText : function (e) {
console.log("Text modified");
}
},
treeListener = {
treeExpanded : function (e) {
console.log("Tree expanded on item: " + e.item.getText());
},

treeCollapsed : function (e) {
console.log("Tree collapsed on item: " + e.item.getText());
}
};

function main() {
// text
text = new gara.jswt.widgets.Text(document.getElementById("text"));
text.addModifyListener(modifyListener);

// list
list = new gara.jswt.widgets.List(document.getElementById("list"), gara.jswt.JSWT.MULTI);
for (var i = 1; i <= 20; i++) {
new gara.jswt.widgets.ListItem(list).setText("Item " + i);
}

list.addControlListener(controlListener);
list.addMouseTrackListener(controlListener);
//list.addMouseMovecontrolListener(controlListener);
list.addMouseWheelListener(controlListener);

list.setHeight(200);

//tree
tree = new gara.jswt.widgets.Tree(document.getElementById("tree"));
tree.addTreeListener(treeListener);
tree.setHeight(200);

var movies = new gara.jswt.widgets.TreeItem(tree).setText("Movies");
new gara.jswt.widgets.TreeItem(movies).setText("300!");
new gara.jswt.widgets.TreeItem(movies).setText("Bud Spencer and Terrance Hill");
new gara.jswt.widgets.TreeItem(movies).setText("Last Samurai");

var series = new gara.jswt.widgets.TreeItem(tree).setText("Series");
new gara.jswt.widgets.TreeItem(series).setText("Two and a half man");
new gara.jswt.widgets.TreeItem(series).setText("Big Bang");
new gara.jswt.widgets.TreeItem(series).setText("Monk");
}
</script>
</head>
<body style="padding: 10px;">
<h1 style="font-size: 24px; margin-bottom: 10px;">Text + Modify Listener</h1>
<div id="text" class="sand"></div>

<div style="width: 300px; float: left;">
<h1 style="font-size: 24px; margin-bottom: 10px;">List + Control Listener</h1>
<div id="list" class="sand" style="border: 1px solid #888;"></div>
</div>

<div style="margin-left: 320px; width: 300px;">
<h1 style="font-size: 24px; margin-bottom: 10px;">Tree + Tree Listener</h1>
<div id="tree" class="sand" style="border: 1px solid #888;"></div>
</div>

<script type="text/javascript">
gara.require(["gara.jswt.widgets.List", "gara.jswt.widgets.Text", "gara.jswt.widgets.Tree"], main);
</script>
</body>
</html>
10 changes: 8 additions & 2 deletions src/gara.js
Expand Up @@ -57,15 +57,21 @@ if (typeof(gara) !== "undefined") {
fireChain, fireReady, fireSuper, chainSuper, fixContexts, fixDescriptor,
Class = function () {}, PropModifier;

// Language fixes
// Language fixes and additions
// #########################################################################

if (typeof Array.isArray !== 'function') {
Array.isArray = function (value) {
return Object.prototype.toString.apply(value) === '[object Array]';
};
}


if (typeof Array.prototype.add === "undefined") {
Array.prototype.add = function (value) {
this[this.length] = value;
};
}

// Default config
// #########################################################################

Expand Down
61 changes: 61 additions & 0 deletions src/gara.jswt.events/ControlListener.js
@@ -0,0 +1,61 @@
/* $Id: FocusListener.interface.js 91 2007-12-09 18:58:43Z tgossmann $
gara - Javascript Toolkit
===========================================================================
Copyright (c) 2007 Thomas Gossmann
Homepage:
http://gara.creative2.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
===========================================================================
*/

gara.provide("gara.jswt.events.ControlListener");

/**
* @interface ControlListener
* @summary
* Classes which implement this interface provide methods that deal with the events
* that are generated by moving and resizing controls.
*
* @description
* After creating an instance of a class that implements this interface it can be
* added to a control using the <code>addControlListener</code> method and removed using
* the <code>removeControlListener</code> method. When a control is moved or resized,
* the appropriate method will be invoked.
*
* @namespace gara.jswt.events
*/

gara.Class("gara.jswt.events.ControlListener", {

/**
* @method
* Sent when the location (x, y) of a control changes
* relative to its parent (or relative to the display, for Shells).
*
* @param {Event} e an event containing information about the mouse move
* @return {void}
*/
controlMoved : function() {},

/**
* @method
* Sent when the size (width, height) of a control changes.
*
* @param {Event} e an event containing information about the mouse move
* @return {void}
*/
controlResized : function() {}
});
12 changes: 11 additions & 1 deletion src/gara.jswt.events/ModifyListener.js
Expand Up @@ -25,7 +25,17 @@ gara.provide("gara.jswt.events.ModifyListener");

/**
* @interface ModifyListener
* @author Thomas Gossmann
*
* @summary
* Classes which implement this interface provide a method that deals with
* the events that are generated when text is modified.
*
* @description
* After creating an instance of a class that implements this interface it
* can be added to a text widget using the <code>addModifyListener</code>
* method and removed using the <code>removeModifyListener</code> method.
* When the text is modified, the modifyText method will be invoked.
*
* @namespace gara.jswt.events
*/

Expand Down
51 changes: 51 additions & 0 deletions src/gara.jswt.events/MouseMoveListener.js
@@ -0,0 +1,51 @@
/* $Id: FocusListener.interface.js 91 2007-12-09 18:58:43Z tgossmann $
gara - Javascript Toolkit
===========================================================================
Copyright (c) 2007 Thomas Gossmann
Homepage:
http://gara.creative2.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
===========================================================================
*/

gara.provide("gara.jswt.events.MouseMoveListener");

/**
* @interface MouseListener
*
* @summary
* Classes which implement this interface provide a method that deals with the events that are
* generated as the mouse pointer moves.
*
* @description
* After creating an instance of a class that implements this interface it can be added to a
* control using the <code>addMouseMoveListener</code> method and removed using the
* <code>removeMouseMoveListener</code> method. As the mouse moves, the mouseMove method will
* be invoked.
*
* @namespace gara.jswt.events
*/
gara.Class("gara.jswt.events.MouseMoveListener", {

/**
* @method
* Sent when the mouse moves.
*
* @param {Event} e an event containing information about the mouse move
* @return {void}
*/
mouseMove : function(e) {}
});
52 changes: 52 additions & 0 deletions src/gara.jswt.events/MouseWheelListener.js
@@ -0,0 +1,52 @@
/* $Id: FocusListener.interface.js 91 2007-12-09 18:58:43Z tgossmann $
gara - Javascript Toolkit
===========================================================================
Copyright (c) 2007 Thomas Gossmann
Homepage:
http://gara.creative2.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
===========================================================================
*/

gara.provide("gara.jswt.events.MouseWheelListener");

/**
* @interface MouseListener
*
* @summary
* Classes which implement this interface provide a method that deals with the event that is
* generated as the mouse wheel is scrolled.
*
* @description
* After creating an instance of a class that implements this interface it can be added to a
* control using the <code>addMouseWheelListener</code> method and removed using the
* <code>removeMouseWheelListener</code> method. When the mouse wheel is scrolled the
* mouseScrolled method will be invoked.
*
* @namespace gara.jswt.events
*/
gara.Class("gara.jswt.events.MouseWheelListener", {

/**
* @method
* Sent when the mouse wheel is scrolled.
*
* @author Thomas Gossmann
* @param {Event} e an event containing information about the mouse wheel action
* @return {void}
*/
mouseScrolled : function(e) {}
});

0 comments on commit 00f1efa

Please sign in to comment.