Re: [Wicket-user] CTRL+click

2006-08-07 Thread Frank Bille
On 8/3/06, 
p.jasson 
[EMAIL PROTECTED] wrote:I have a markup container with AjaxEvenBehavior for 'onclick'.
In the onEvent method i need to know whether CTRL was pressed during theclick or no.How can it be done?If you need to know it on the server you have to change the request url on the AJAX request to add some parameters for it. Something like this perhaps:
package wicket.sandbox.pages;import java.util.regex.Matcher;import java.util.regex.Pattern;import wicket.Request;import wicket.RequestCycle;import wicket.ajax.AjaxEventBehavior;
import wicket.ajax.AjaxRequestTarget;/*** AJAX Behavior which returns the client side click information to the server. You get information like* is CTRL/ALT/SHIFT key pressed and x and y of the mouse position. 
* * @author Frank Bille (billen)*/public abstract class ClickBehavior extends AjaxEventBehavior { public ClickBehavior() {  super(onclick); }  protected CharSequence getCallbackScript(CharSequence partialCall, CharSequence onSuccessScript, CharSequence onFailureScript) {
  String superCallbackScript = super.getCallbackScript(partialCall, onSuccessScript, onFailureScript).toString();Pattern pat = Pattern.compile(^wicketAjaxGet\\('([^']+)'$);
  Matcher mat = pat.matcher(partialCall);if (mat.matches()) {   StringBuffer url = "" StringBuffer(mat.group(1));  // CtrlClick   url.append
();   url.append(ctrlKey='+event.ctrlKey+');   url.append();   url.append(altKey='+event.altKey+');   url.append
();   url.append(shiftKey='+event.shiftKey+');   url.append();   url.append(xPos='+event.clientX+');   url.append
();   url.append(yPos='+event.clientY+');  superCallbackScript = superCallbackScript.replace(mat.group(1), url.toString());  }  
  return superCallbackScript; } protected final void onEvent(AjaxRequestTarget target) {  Request request = RequestCycle.get().getRequest();boolean ck = Boolean.parseBoolean
(request.getParameter(ctrlKey));  boolean ak = Boolean.parseBoolean(request.getParameter(altKey));  boolean sk = Boolean.parseBoolean(request.getParameter(shiftKey));
  int x = Integer.parseInt(request.getParameter(xPos));  int y = Integer.parseInt(request.getParameter(yPos));onEvent(target, new ClickEvent(ck, ak, sk, x, y));
 } protected abstract void onEvent(AjaxRequestTarget target, ClickEvent event);  public static class ClickEvent {  private boolean ctrlKey;private boolean altKey;
private boolean shiftKey;private int x;private int y;public ClickEvent(boolean ctrlKey, boolean altKey, boolean shiftKey, int x, int y) {
   this.ctrlKey = ctrlKey;   this.altKey = altKey;   this.shiftKey = shiftKey;   this.x = x;   this.y = y;  }  public boolean isAltKey() {
   return altKey;  }  public boolean isCtrlKey() {   return ctrlKey;  }  public boolean isShiftKey() {   return shiftKey;  }
  public int getX() {   return x;  }  public int getY() {   return y;  } }}
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


Re: [Wicket-user] CTRL+click

2006-08-06 Thread Frank Bille
HeyYou can use the callbackdecorator to add the _javascript_ which you need. Something like this perhaps:component.add(new AjaxEventBehavior(onclick) { private static final long serialVersionUID = 1L;
 protected void onEvent(AjaxRequestTarget target) { target.appendJavascript(alert('hey');); } protected CharSequence getCallbackScript(CharSequence partialCall, CharSequence onSuccessScript, CharSequence onFailureScript) {
 String callbackScript = super.getCallbackScript(partialCall, onSuccessScript, onFailureScript).toString(); callbackScript = if(event.ctrlKey == false) return false;+callbackScript;
return callbackScript;  }  });FrankOn 8/3/06, p.jasson 
[EMAIL PROTECTED] wrote:I have a markup container with AjaxEvenBehavior for 'onclick'.
In the onEvent method i need to know whether CTRL was pressed during theclick or no.How can it be done?Thanks.--View this message in context: 
http://www.nabble.com/CTRL%2Bclick-tf2047972.html#a5640400Sent from the Wicket - User forum at Nabble.com.-
Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___Wicket-user mailing listWicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user


[Wicket-user] CTRL+click

2006-08-03 Thread p.jasson

I have a markup container with AjaxEvenBehavior for 'onclick'.
In the onEvent method i need to know whether CTRL was pressed during the
click or no.
How can it be done?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/CTRL%2Bclick-tf2047972.html#a5640400
Sent from the Wicket - User forum at Nabble.com.


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT  business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.phpp=sourceforgeCID=DEVDEV
___
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user