[KSS-checkins] r50977 - kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo
jone at codespeak.net
jone at codespeak.net
Thu Jan 24 17:23:14 CET 2008
Author: jone
Date: Thu Jan 24 17:23:13 2008
New Revision: 50977
Added:
kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.css
kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.kss
kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.pt
kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.py
kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.zcml
Modified:
kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/configure.zcml
kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/zopeconfig.py
Log:
added a demo using the new mouse informations (positions, buttons)
Modified: kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/configure.zcml
==============================================================================
--- kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/configure.zcml (original)
+++ kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/configure.zcml Thu Jan 24 17:23:13 2008
@@ -583,5 +583,8 @@
<!-- CursorTest -->
<include file="snake.zcml" />
+ <!-- MouseTest -->
+ <include file="mousetest.zcml" />
+
</configure>
Added: kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.css
==============================================================================
--- (empty file)
+++ kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.css Thu Jan 24 17:23:13 2008
@@ -0,0 +1,39 @@
+
+div#mousearea {
+ background-color: #EAEACD;
+ border: 1px solid #A8A890;
+ height: 400px;
+}
+
+div#haunter {
+ background-color: red;
+ position: absolute;
+ height: 5px;
+ width: 5px;
+}
+
+ul#contextMenu {
+ background-color: #A0A0A0;
+ list-style: none;
+ padding: 0px;
+ width: 100px;
+ position: absolute;
+}
+
+ul#contextMenu.hidden {
+ display: none;
+}
+
+ul#contextMenu li {
+ list-style: none;
+}
+
+ul#contextMenu a {
+ display: block;
+ color: black;
+ text-decoration: none;
+}
+
+ul#contextMenu a:hover {
+ background-color: #C0C0C0;
+}
Added: kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.kss
==============================================================================
--- (empty file)
+++ kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.kss Thu Jan 24 17:23:13 2008
@@ -0,0 +1,20 @@
+
+div#mousearea:mousemove {
+ action-server: mousetest_move;
+ mousetest_move-clientX: pass(clientX);
+ mousetest_move-clientY: pass(clientY);
+}
+
+div#mousearea:mousedown, div#haunter:mousedown {
+ evt-mousedown-preventdefault: true;
+ action-server: mousetest_contextmenu;
+ mousetest_contextmenu-clientX: pass(clientX);
+ mousetest_contextmenu-clientY: pass(clientY);
+ mousetest_contextmenu-button: pass(button);
+}
+
+a.menuitem:click {
+ evt-click-preventdefault: true;
+ action-server: mousetest_contextmenu_click;
+ mousetest_contextmenu_click-action: nodeAttr(id);
+}
Added: kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.pt
==============================================================================
--- (empty file)
+++ kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.pt Thu Jan 24 17:23:13 2008
@@ -0,0 +1,34 @@
+<html tal:define="viewname string:mousetest">
+
+ <head>
+
+ <title>Mousetest</title>
+
+ <metal:header use-macro="context/@@header_macros/header_resources" />
+ <link rel="stylesheet" type="text/css"
+ tal:attributes="href
+ string:${context/@@absolute_url}/++resource++${viewname}.css"/>
+
+ </head>
+
+ <body>
+
+ <p metal:use-macro="context/@@body_macros/header">header</p>
+
+ <h2>Mousetest</h2>
+
+ Move the mouse around inside the area below. The red point should follow. For increasing and decreasing the size right click in the area.
+
+ <div id="mousearea">
+ <div id="haunter"></div>
+ </div>
+
+ <ul id="contextmenu" class="hidden">
+ <li><a href="#" id="menu_bigger" class="menuitem">Bigger</a></li>
+ <li><a href="#" id="menu_smaller" class="menuitem">Smaller</a></li>
+ <li><a href="#" id="menu_hide" class="menuitem">Hide</a></li>
+ </ul>
+
+
+ </body>
+</html>
Added: kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.py
==============================================================================
--- (empty file)
+++ kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.py Thu Jan 24 17:23:13 2008
@@ -0,0 +1,68 @@
+# Copyright (c) 2005-2007
+# Authors: KSS Project Contributors (see docs/CREDITS.txt)
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+from kss.core import KSSView, force_unicode, KSSExplicitError, kssaction
+from time import time
+from persistent.list import PersistentList
+
+class KSSMouseTestDemo(KSSView):
+
+ def move(self, clientX, clientY):
+ self.getCommandSet('core').setStyle('div#haunter', 'left', '%spx' % str(int(clientX) - 5))
+ self.getCommandSet('core').setStyle('div#haunter', 'top', '%spx' % str(int(clientY) - 5))
+ return self.render()
+
+
+ def contextmenu(self, clientX, clientY, button):
+ clientX = int(clientX)
+ clientY = int(clientY)
+ button = int(button)
+ if button==0:
+ self.getCommandSet('core').removeClass('ul#contextmenu', 'hidden');
+ self.getCommandSet('core').addClass('ul#contextmenu', 'hidden');
+ elif button==2:
+ self.getCommandSet('core').removeClass('ul#contextmenu', 'hidden');
+ self.getCommandSet('core').setStyle('ul#contextmenu', 'left', '%spx' % int(clientX))
+ self.getCommandSet('core').setStyle('ul#contextmenu', 'top', '%spx' % int(clientY))
+ return self.render()
+
+ def contextmenu_click(self, action):
+ w, h = self.getHaunterSize()
+ if action=='menu_bigger':
+ w += 5
+ h += 5
+ elif action=='menu_smaller':
+ w -= 5
+ h -= 5
+ elif action=='menu_hide':
+ pass
+ self.getCommandSet('core').setStyle('div#haunter', 'width', str(w))
+ self.getCommandSet('core').setStyle('div#haunter', 'height', str(h))
+ self.getCommandSet('core').addClass('ul#contextmenu', 'hidden');
+ self.setHaunterSize(w, h)
+ print 'asdf'
+ return self.render()
+
+
+ def getHaunterSize(self):
+ w = self.request.SESSION.get('haunter_w', 5)
+ h = self.request.SESSION.get('haunter_h', 5)
+ return w, h
+
+ def setHaunterSize(self, w, h):
+ self.request.SESSION['haunter_w'] = w
+ self.request.SESSION['haunter_h'] = h
Added: kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.zcml
==============================================================================
--- (empty file)
+++ kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/mousetest.zcml Thu Jan 24 17:23:13 2008
@@ -0,0 +1,52 @@
+<configure xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ xmlns:kss="http://namespaces.zope.org/kss"
+ xmlns:zcml="http://namespaces.zope.org/zcml"
+ i18n_domain="kss"
+ >
+
+ <!-- Typewriter -->
+ <browser:page
+ for="kss.demo.interfaces.ISimpleContent"
+ class=".mousetest.KSSMouseTestDemo"
+ template="mousetest.pt"
+ name="mousetest.html"
+ permission="zope.View"
+ />
+
+ <browser:resource
+ file="mousetest.kss"
+ name="mousetest.kss"
+ />
+
+ <browser:resource
+ file="mousetest.css"
+ name="mousetest.css"
+ />
+
+ <browser:page
+ for="kss.demo.interfaces.ISimpleContent"
+ class=".mousetest.KSSMouseTestDemo"
+ attribute="move"
+ name="mousetest_move"
+ permission="zope.View"
+ />
+
+ <browser:page
+ for="kss.demo.interfaces.ISimpleContent"
+ class=".mousetest.KSSMouseTestDemo"
+ attribute="contextmenu_click"
+ name="mousetest_contextmenu_click"
+ permission="zope.View"
+ />
+
+ <browser:page
+ for="kss.demo.interfaces.ISimpleContent"
+ class=".mousetest.KSSMouseTestDemo"
+ attribute="contextmenu"
+ name="mousetest_contextmenu"
+ permission="zope.View"
+ />
+
+</configure>
+
Modified: kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/zopeconfig.py
==============================================================================
--- kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/zopeconfig.py (original)
+++ kukit/kss.core/branch/extend-mouseover/kss/core/plugins/core/demo/zopeconfig.py Thu Jan 24 17:23:13 2008
@@ -28,6 +28,7 @@
description = 'A simple implementation of the infamous snake game',
helpfile = 'snake.rst',
packageName = 'kss.core.plugins.core.demo'),
+ KSSDemo('', 'Applications', 'mousetest.html', 'Mouse Test'),
## KSSDemo('', '', "draganddrop.html", "Scriptaculous drag and drop"),
KSSDemo('', 'Parameter functions', 'pf_forms.html', 'Forms'),
KSSDemo('', 'Selectors', 'selectors.html', 'Parent node selector'),
More information about the Kukit-checkins
mailing list