ClickAgent"

From Documentation
 
(6 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
= Click, Double-Click, Right-Click =
 
= Click, Double-Click, Right-Click =
  
<tt> ClickAgent </tt> helps us to mimic the clicking of a component for general intention; it is able to trigger <b>onClick</b>, <b>onDoubleClick</b>, or <b>onRightClick</b> events. Most user actions are done by clicking, but they might have different intentions. For example, clicking a <b>listitem</b> would represent selecting it, by clicking on a <b>checkbox</b> would represents checking the box and so on. Therefore, to avoid mixing several actions into clicking operations, specific actions has different corresponding operation agents. For example, if you wanted to select a <b>listitem</b>, use <tt> SelectAgent </tt>,for checkbox, use <tt> CheckAgent </tt>. Which operation agent you choose to use would depend on the intention.
+
<code> ClickAgent </code> helps us to mimic the clicking of a component for general intention; it is able to trigger <b>onClick</b>, <b>onDoubleClick</b>, or <b>onRightClick</b> events. Most user actions are done by clicking, but they might have different intentions. For example, clicking a <b>listitem</b> would represent selecting it; clicking on a <b>checkbox</b> would represent checking the box and so on. Therefore, to avoid mixing several actions into clicking operations, specific actions have different corresponding operation agents. For example, if you wanted to select a <b>listitem</b>, use <code> SelectAgent </code>,for checkbox, use <code> CheckAgent </code>. Which operation agent you choose would depend on the intention.
  
According to [http://books.zkoss.org/wiki/ZK_Component_Reference/Base_Components/HtmlBasedComponent ZK Component Referenece], '''all components that inherit <tt> HtmlBasedComponent </tt> support click, double click, and right click'''.
+
According to [http://books.zkoss.org/wiki/ZK_Component_Reference/Base_Components/HtmlBasedComponent ZK Component Referenece], '''all components that inherit <code> HtmlBasedComponent </code> supports click, double click, and right click'''.
  
 
'''ClickTest.java'''
 
'''ClickTest.java'''
  
<source lang="java" high="12,15,18">
+
<source lang="java" highlight="12,15,18">
 
public class ClickTest {
 
public class ClickTest {
  
Line 37: Line 37:
 
* As mentioned in the previous section, it's a shortcut method for convenience. (line 12)
 
* As mentioned in the previous section, it's a shortcut method for convenience. (line 12)
  
* If you want to perform double click or right click, you have get <tt> ClickAgent </tt> first from <tt> ComponentAgent </tt>. (line 15,18)
+
* If you want to perform double click or right click, you have to get <code> ClickAgent </code> first from <code> ComponentAgent </code>. (line 15,18)
 
 
  
 
=Supported Components=
 
=Supported Components=
  
  {| border="1" | width="100%"
+
  {| class='wikitable' | width="100%"
 
! <center>Components</center>
 
! <center>Components</center>
 
! <center>Version</center>
 
! <center>Version</center>
 
! <center>Note</center>
 
! <center>Note</center>
 
|-
 
|-
| Sub-class of HtmlBasedComponent  
+
| Sub-class of <javadoc> org.zkoss.zk.ui.HtmlBasedComponent </javadoc>
 
| 5, 6
 
| 5, 6
 
|
 
|
Line 53: Line 52:
  
  
 +
 +
{{ZATSEssentialsPageHeader}}
 
{{ZATSEssentialsPageFooter}}
 
{{ZATSEssentialsPageFooter}}

Latest revision as of 03:11, 24 April 2023


Click, Double-Click, Right-Click

ClickAgent helps us to mimic the clicking of a component for general intention; it is able to trigger onClick, onDoubleClick, or onRightClick events. Most user actions are done by clicking, but they might have different intentions. For example, clicking a listitem would represent selecting it; clicking on a checkbox would represent checking the box and so on. Therefore, to avoid mixing several actions into clicking operations, specific actions have different corresponding operation agents. For example, if you wanted to select a listitem, use SelectAgent ,for checkbox, use CheckAgent . Which operation agent you choose would depend on the intention.

According to ZK Component Referenece, all components that inherit HtmlBasedComponent supports click, double click, and right click.

ClickTest.java

public class ClickTest {

	//remove other methods for brevity

	@Test
	public void test() {
		DesktopAgent desktop = Zats.newClient().connect("/click.zul");

		ComponentAgent label = desktop.query("#mylabel");
		ComponentAgent eventName = desktop.query("#eventName");
		
		label.click();
		assertEquals("onClick", eventName.as(Label.class).getValue());
		
		label.as(ClickAgent.class).doubleClick();
		assertEquals("onDoubleClick", eventName.as(Label.class).getValue());
		
		label.as(ClickAgent.class).rightClick();
		assertEquals("onRightClick", eventName.as(Label.class).getValue());
	}
}
  • As mentioned in the previous section, it's a shortcut method for convenience. (line 12)
  • If you want to perform double click or right click, you have to get ClickAgent first from ComponentAgent . (line 15,18)

Supported Components

Components
Version
Note
Sub-class of HtmlBasedComponent 5, 6





Last Update : 2023/04/24

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.