Tizen Native API
|
In this example we will make use of signals to help to move an image away from the mouse pointer.
Signals are software interruption, this means that when it happens and if the program is sensitive to it the program will stop whatever it is doing and handle the signal.
In this example we are only sensitive to the "mouse,move" signal so we need to register a callback to it. To do this we will add a signal callback to our edje object that will detect "mouse,move" signal coming from the part "part_image" and when this happens we will call the function _on_mouse_over passing the evas pointer as a parameter. The evas pointer is passed as a parameter because we need to know where is the mouse pointer in the screen.
We can see bellow how we can listen to the signal:
Now, let's pass to the callback function. If we want to keep the ball away from the mouse pointer we need to now where is the ball and where is the mouse and we can easily discovery these things using this:
For the object position in the canvas:
For the mouse position relative to the screen:
Now that we have the position of the mouse and the object we just need to set the new location and move the object. To set the new location we do this:
You can change the formula above if you like. Because we are changing the object's position we need to do something if the new position is beyond the canvas size. So here it is:
Then now what we need to do is move the object:
Here is the complete callback function:
When you compile and run it you should see this:
The .edc file:
The source code:
To compile use this command:
* gcc -o signals2 signals2.c -DPACKAGE_BIN_DIR=\"/Where/enlightenment/is/installed/bin\" * -DPACKAGE_LIB_DIR=\"/Where/enlightenment/is/installed/lib\" * -DPACKAGE_DATA_DIR=\"/Where/enlightenment/is/installed/share\" * `pkg-config --cflags --libs evas ecore ecore-evas edje` * * edje_cc -id /path/to/the/image signalsBubble.edc *