« Back to AAU Project

Do on mouse click some graphics...

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Do on mouse click some graphics...
Answer
7/10/15 7:00 AM
Hello, 
I want my graphical representation (rectangle 1) to open a new rectangle (rectangle 2), when the modeller performs a mouse click on a certain area of rectangle 1.
How do I get this reference for the mouse click? 

Thanks and BR,Mel

RE: Do on mouse click some graphics...
Answer
7/10/15 9:51 AM as a reply to Melanie Schranz.
Dear Melanie,
Thank you for your question. In order to realize your scenario you would need an attribute of type PROGRAMCALL with what you can trigger an AdoScript code for creating a new object. For executing this from the graphical notation of the object you have define a HOTSPOT within your GraphRep attribute.
You can find the GraphRep documentation and the syntax at the following link:
http://www.adoxx.org/live/adoxx-notation-language-graphrep

Please find below an example library, and the step by step documentation how the implement the scenario.

1) Create Class with Name "A"

2) Create Attribute in the 'Create Object' of type PROGRAMCALL and edit the following parameters:

-Standard value:
1CreateObject

-EnumerationDomain:
 1ITEM "CreateObject"
 2SET n_ObjId: (objid)
 3CC "Modeling" GET_ACT_MODEL
 4SET nModelId: (modelid)
 5CC "Core" GET_CLASS_ID objid: (n_ObjId)
 6SET nClassId: (classid)
 7CC "AdoScript" EDITBOX text:"Enter object name!"  title:"Enter object name!"
 8SET sName: (text)
 9CC "Core" CREATE_OBJ modelid: (modelid) classid: (nClassId) objname: (sName)
10#-->RESULT ecode:intValue  objid:intValue
11SET sNewObjId: (objid)
12#Object names have to be unique
13  IF (ecode!=0) {
14    CC "AdoScript" ERRORBOX "The Name You have Chosen is not Unique!"
15    EXIT
16  }
17#Position the created new object
18CC "Core" GET_ATTR_VAL objid: (n_ObjId) attrname:"Position"
19SET sObjpos: (val)
20LEO parse: (sObjpos)   
21       get-str-value:xPos:"x"   
22       get-str-value:yPos:"y"
23SET xNewPos:    ((VAL xPos) + CM 4)
24SET yNewPos: ((VAL yPos) + CM 3)
25CC "Modeling" SET_OBJ_POS objid: (sNewObjId) x: (xNewPos) y: (yNewPos)

3) Define GraphRep

1GRAPHREP
2FILL color:green
3RECTANGLE x:-1.2cm y:-0.8cm w:2.4cm h:1.6cm
4FILL color:red
5RECTANGLE x:0 y:-0.8cm w:1.2cm h:0.8cm
6HOTSPOT "Create Object" x:0 y:-0.8cm w:1.2cm h:0.8cm

In this graphrep definition the HOTSPOT triggers the attribute "Create Object" in the area x:[0cm,1.2cm], y:[-0.8cm,0cm] (red rectangle in the screenshot)




Attachments: Create Object with HOTSPOT Library.abl (9.9k)

RE: Do on mouse click some graphics...
Answer
7/10/15 10:11 AM as a reply to Mehmet Albayrak.
Thanx

RE: Do on mouse click some graphics...
Answer
7/15/15 2:05 PM as a reply to Mehmet Albayrak.
Thank you very much for your detailed answer!

I have a, somehow, related question:
Is it possible to get with HOTSPOT a return value like: true ("area clicked with mouse") or false ("area not clicked with mouse")?
Or related, like a string "clicked" and "not_clicked" to differ and work further with this value in GraphRep?

RE: Do on mouse click some graphics...
Answer
7/21/15 11:38 AM as a reply to Melanie Schranz.
Dear Melanie, 

You can make a workaround with a 'hidden' attribute and set the attribute value to 'True' during your implementation. You can read the value of this attribute in the graphRep then with AVAL. For this scenario, please follow the steps below:

1) Create attribute: 'Clicked' of type ENUMERATION with the Enumeration Domain: False@True
2) Add a Command in your AdoScript that the value of the attribute "Clicked" should be set to true.

1CC "Core" SET_ATTR_VAL objid: (n_ObjId) attrname:"Clicked" val:"True"

3) Configure GraphRep:

1AVAL sClicked:"Clicked"
2IF (sClicked="True")
3...
4ENDIF

RE: Do on mouse click some graphics...
Answer
7/27/15 10:10 AM as a reply to Mehmet Albayrak.
Thank you very much, this brought me a big step further!
A small thing is still open: 

Is it possible to erase a line, in this style: 


AVAL t1:"ID"
LINE x1:1.1cm x2:1.1cm y1:-0.6cm y2:0.6cm

IF(t1!=" ")
{
"ERASE LINE x1:1.1cm x2:1.1cm y1:-0.6cm y2:0.6cm"
}
ENDIF

I wasn't able to find an appropriate command!

Thanks and best regards, Melanie

RE: Do on mouse click some graphics...
Answer
7/27/15 10:29 AM as a reply to Melanie Schranz.
Dear Melanie,
Thank you for your question. Unfortunately there is no command to erase a line in the GraphRep definition. Nevertheless you can try one of the following two approaches.

1) Draw a white line on the line.
2) Work with the opposite 'if' condition. In this approach you draw the line if the value of the attribute "ID" is " " and no line else (see code below). 

1AVAL t1:"ID"
2IF(t1=" ")
3LINE x1:1.1cm x2:1.1cm y1:-0.6cm y2:0.6cm
4ENDIF

RE: Do on mouse click some graphics...
Answer
7/27/15 10:54 AM as a reply to Mehmet Albayrak.
Thank you very much for the quick answer!