Hi Guys,
I'm trying to detect the mouse click on specific object(s) during simulation (object is a shape).
Firstly i tried to do If statement comparing the .Component (what is the Ev_Click Macro parameter) and the Handle name of component. I noticed that the variables associated are 'Handle' type but it looks this are just a U variables. However by looking deeper i noticed that the variable do not mach.
I made lite project printing the value on the panel, and you can see what is wrong:
Mouse click handle and the object handle appear to be in offset. I'm sure this should be a bug. If i compare variables i will not get the expected return.
In this case i want to detect the click on B0 and flip the color on mouse click. There is no problem if this offset is permanent, but in my diferent project this offset looks random to me.
Now i'm puzzled, how i detect or enable mouse click on only specific objects?
Regards,
Igor
Simulation objects detection method
-
- Posts: 78
- Joined: Mon Jul 31, 2017 11:14 am
- Has thanked: 7 times
- Been thanked: 13 times
Simulation objects detection method
- Attachments
-
- Object detection by Handle name.fcfx
- (15.44 KiB) Downloaded 210 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Simulation objects detection method
Hello Igor,
Please look at my example I posted here.
viewtopic.php?f=7&t=19177#p83688
I created a macro that will dig down into a component to check if the handle your looking for is the root level component or a child of that component.
The problem is that primitive shape objects catch the click event, however in Flowcode 7 we wrapped the primitive objects up as components so the top level root node of the object is the component and not the primitive shape.
The macro I created in the example can be exported and imported into your new project and used in your decision inside the Ev_Click macro.
Previously in v6 primitive objects were not wrapped in components and so the drill down was not required but this consumed precious screen space as part of the panel windows.
Please look at my example I posted here.
viewtopic.php?f=7&t=19177#p83688
I created a macro that will dig down into a component to check if the handle your looking for is the root level component or a child of that component.
The problem is that primitive shape objects catch the click event, however in Flowcode 7 we wrapped the primitive objects up as components so the top level root node of the object is the component and not the primitive shape.
The macro I created in the example can be exported and imported into your new project and used in your decision inside the Ev_Click macro.
Previously in v6 primitive objects were not wrapped in components and so the drill down was not required but this consumed precious screen space as part of the panel windows.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 78
- Joined: Mon Jul 31, 2017 11:14 am
- Has thanked: 7 times
- Been thanked: 13 times
Re: Simulation objects detection method
Hi Ben,
unfortunately, I still have the issue of getting the correct ID for the object. If I compile the component and run the component in the new project simulation, the IDs are all screwed, and there is no way to determine on startup what they are. I coded an offset of this child ID, but this is also changed when the component is compiled (offset changes randomly).
This is really a problem which I can not work around in order to create satisfactory UI for the simulation.
Any idea how to work around this one? Your example is working only inside that same macro using ID which is obtained by a mouse click on the object (this) but we still do not know which object was clicked on.
I need to be able to get the status of the object and put it into the variable so it can be used in other code. I do not know how to do this efficiently.
I could search for changes of the properties for all objects before property change and after the change, in order to determine the actual object. But it seems to me that I'm writing now low-level FC component, instead of being focused on my algorithm and creation of UI.
It seems to me you will need to fix the bug with this child IDs.
Thanks,
Igor
unfortunately, I still have the issue of getting the correct ID for the object. If I compile the component and run the component in the new project simulation, the IDs are all screwed, and there is no way to determine on startup what they are. I coded an offset of this child ID, but this is also changed when the component is compiled (offset changes randomly).
This is really a problem which I can not work around in order to create satisfactory UI for the simulation.
Any idea how to work around this one? Your example is working only inside that same macro using ID which is obtained by a mouse click on the object (this) but we still do not know which object was clicked on.
I need to be able to get the status of the object and put it into the variable so it can be used in other code. I do not know how to do this efficiently.
I could search for changes of the properties for all objects before property change and after the change, in order to determine the actual object. But it seems to me that I'm writing now low-level FC component, instead of being focused on my algorithm and creation of UI.
It seems to me you will need to fix the bug with this child IDs.
Thanks,
Igor