catch BFM_INPUT_DOUBLECLICK in GeUserArea [SOLVED]
-
On 13/01/2015 at 09:56, xxxxxxxx wrote:
I think, you got the BFM_INPUT_DOUBLECLICK wrong (you are comparing the container ID to a bool).
Try it like so:Bool nodeUserArea::InputEvent(const BaseContainer& msg) { GeData data; // check if mouse event msg.GetParameter(DescLevel(BFM_INPUT_DEVICE), data); if (data.GetInt32() == BFM_INPUT_MOUSE) { // check if left mouse button msg.GetParameter(DescLevel(BFM_INPUT_CHANNEL), data); if (data.GetInt32() == BFM_INPUT_MOUSELEFT) { // now get the coordinates msg.GetParameter(DescLevel(BFM_INPUT_X), data); const Int32 xCoordiante = data.GetInt32(); msg.GetParameter(DescLevel(BFM_INPUT_Y), data); const Int32 yCoordiante = data.GetInt32(); GePrint("UserArea hit at " + String::IntToString(xCoordiante) + " : " + String::IntToString(yCoordiante)); msg.GetParameter(DescLevel(BFM_INPUT_DOUBLECLICK), data); if (data.GetBool()) { GePrint("UserArea double click at " + String::IntToString(xCoordiante) + " : " + String::IntToString(yCoordiante)); addNode(xCoordiante, yCoordiante); Redraw(); } } } return true; };
-
On 13/01/2015 at 10:05, xxxxxxxx wrote:
hi Andreas,
thanks for the reply, I guess what you did should work "will test soon" , but at the same time it is kinda weird!!
I assume all BFM_INPUT_............ should work the same way, so BFM_INPUT_MOUSELEFT and BFM_INPUT_DOUBLECLICK should be called the same way "regardless of comparing with GetInt32 or GetBool!!"
-
On 13/01/2015 at 10:09, xxxxxxxx wrote:
Mohamed,
I'm sorry, I don't understand. There's nothing special about BFM_INPUT_...
You are retrieving values from the message BaseContainer. And the values stored in there have different types. You need to retrieve them correctly. And comparing a boolean value to an container ID (which is most likely not zero or one) is bound to have false as a result. -
On 13/01/2015 at 10:12, xxxxxxxx wrote:
well, tell me if those 2 snippets are doing the same thing:
msg.GetParameter(DescLevel(BFM_INPUT_CHANNEL), data); if (data.GetInt32() == BFM_INPUT_MOUSELEFT)
msg.GetParameter(DescLevel(BFM_INPUT_MOUSELEFT), data); if(data.GetInt32())
-
On 13/01/2015 at 10:19, xxxxxxxx wrote:
No, they are not.
a) This is correct. The comparison is only true, if the value stored at container ID (or rather description ID) BFM_INPUT_CHANNEL is equal to BFM_INPUT_MOUSELEFT.
b) Wrong. BFM_INPUT_MOUSELEFT is not a container ID, but rather a define for one of the values, that may be stored at container ID BFM_INPUT_CHANNEL. You should actually get false as return value from msg.GetParameter(DescLevel(BFM_INPUT_MOUSELEFT), data); as the value was not found in the container.
-
On 13/01/2015 at 10:22, xxxxxxxx wrote:
I see!! , so container IDs are strings in the header??
BFM_INPUT_CHANNEL = 'ipca'
BFM_INPUT_DOUBLECLICK = 'ipdb'also 1 last thing, which versions of the SDK support Get/Set parameter? 13+?
-
On 13/01/2015 at 10:35, xxxxxxxx wrote:
Hehe
No, they are not. Container IDs are 32-Bit integer values. The notation shown in your post is just another way to write these integer values by composing them from four bytes. Instead of writing the bytes in decimal or hexadecimal, characters are used instead. In this way you get "meaningful" integer values, which can be printed (don't try to put the defines directly into a GePrint though, this won't show you the text you expect).
This is done, as it is simply easier to recognize for humans...Like so (for 'ipca') :
ip short for "input" and ca short for "channel"
i - ASCII or byte value 0x69
p - 0x70
c - 0x63
a - 0x61
So you get: 0x69706361 (1768973153 decimal) as container ID.
The decimal value is what you get, if you use GePrint(String::IntToString(BFM_INPUT_CHANNEL)). -
On 13/01/2015 at 10:39, xxxxxxxx wrote:
so how can I identify container IDs then? lots of definitions in the header.
also does this Get/Set parameter work for R13 SDK? -
On 13/01/2015 at 10:51, xxxxxxxx wrote:
Hm? What do you want to identify? You shouldn't care for the ID values anyway. You should use the defines instead.
Yes, Get/SetParameter() was available in R13 as well.
If you wanted to print the container ID value in a way like it is noted in the definition, you could use a function like this:
void printMsg(UInt32 id) { char v[5]; v[0] = (char)((id & 0xFF000000) >> 24); v[1] = (char)((id & 0x00FF0000) >> 16); v[2] = (char)((id & 0x0000FF00) >> 8); v[3] = (char)(id & 0x000000FF); v[4] = 0; // zero termination of string GePrint(String(v)); }
So printMsg(BFM_INPUT_CHANNEL) prints ipca
-
On 13/01/2015 at 10:54, xxxxxxxx wrote:
thanks a lot Andreas for the help