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 \char`\"{}mouse,move\char`\"{} 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 \char`\"{}mouse,move\char`\"{} signal coming from the part \char`\"{}part\+\_\+image\char`\"{} 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\+:

 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   edje\_object\_signal\_callback\_add(edje\_obj, \textcolor{stringliteral}{"mouse,move"}, \textcolor{stringliteral}{"part\_image"},}
\DoxyCodeLine{                                   \_on\_mouse\_over, evas);}

\end{DoxyCodeInclude}


Now, let\textquotesingle{}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\+:  
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(edje\_obj, \&x, \&y, NULL, NULL);}

\end{DoxyCodeInclude}


For the mouse position relative to the screen\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   evas\_pointer\_output\_xy\_get(evas, \&mouseX, \&mouseY);}

\end{DoxyCodeInclude}


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\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \textcolor{keywordflow}{if} ((rand() \% 2) == 0)}
\DoxyCodeLine{     x += ((mouseX -\/ x) + (x / 4 + mouseY / 2));}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     x -\/= ((mouseX -\/ x) + (x / 4 + mouseY / 2));}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} ((rand() \% 2) == 0)}
\DoxyCodeLine{     y += ((mouseY -\/ y) + (y / 4 + mouseX / 2));}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     y -\/= ((mouseY -\/ y) + (y / 4 + mouseX / 2));}

\end{DoxyCodeInclude}


You can change the formula above if you like. Because we are changing the object\textquotesingle{}s position we need to do something if the new position is beyond the canvas size. So here it is\+:


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (x > WIDTH)}
\DoxyCodeLine{     x = WIDTH;}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (x < 0) x = 0;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (y > HEIGHT)}
\DoxyCodeLine{     y = HEIGHT;}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (y < 0) y = 0;}

\end{DoxyCodeInclude}


Then now what we need to do is move the object\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   evas\_object\_move(edje\_obj, x, y);}

\end{DoxyCodeInclude}


Here is the complete callback function\+:

 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\_on\_mouse\_over(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *edje\_obj,}
\DoxyCodeLine{               \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *source \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *evas;}
\DoxyCodeLine{   \textcolor{keywordtype}{int} x, y, mouseX, mouseY;}
\DoxyCodeLine{}
\DoxyCodeLine{   evas = (\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *) data;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(edje\_obj, \&x, \&y, NULL, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_pointer\_output\_xy\_get(evas, \&mouseX, \&mouseY);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} ((rand() \% 2) == 0)}
\DoxyCodeLine{     x += ((mouseX -\/ x) + (x / 4 + mouseY / 2));}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     x -\/= ((mouseX -\/ x) + (x / 4 + mouseY / 2));}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} ((rand() \% 2) == 0)}
\DoxyCodeLine{     y += ((mouseY -\/ y) + (y / 4 + mouseX / 2));}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     y -\/= ((mouseY -\/ y) + (y / 4 + mouseX / 2));}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (x > WIDTH)}
\DoxyCodeLine{     x = WIDTH;}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (x < 0) x = 0;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (y > HEIGHT)}
\DoxyCodeLine{     y = HEIGHT;}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (y < 0) y = 0;}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Moving object to -\/ (\%d,\%d)\(\backslash\)n"}, x, y);}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_object\_move(edje\_obj, x, y);}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}


When you compile and run it you should see this\+:   
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{signal2final}}
\end{DoxyImageNoCaption}


The .edc file\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{collections\{}
\DoxyCodeLine{   group\{}
\DoxyCodeLine{      name: "image\_group";}
\DoxyCodeLine{      max: 500 500;}
\DoxyCodeLine{      min: 50 50;}
\DoxyCodeLine{      images\{}
\DoxyCodeLine{           image: "bubble.png" COMP;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{    parts\{}
\DoxyCodeLine{            part\{}
\DoxyCodeLine{                   name: "part\_image";}
\DoxyCodeLine{                   type: IMAGE;}
\DoxyCodeLine{                   description\{}
\DoxyCodeLine{                       min:63 63;}
\DoxyCodeLine{                       image\{}
\DoxyCodeLine{                            normal: "bubble.png";}
\DoxyCodeLine{                       \}}
\DoxyCodeLine{                   \}}
\DoxyCodeLine{                 \}}
\DoxyCodeLine{          \}}
\DoxyCodeLine{   \}}
\DoxyCodeLine{\}}
\end{DoxyCodeInclude}


The source code\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{comment}{//Compile with:}}
\DoxyCodeLine{\textcolor{comment}{// edje\_cc signalsBubble.edc \&\& gcc -\/o signals2 signals2.c `pkg-\/config -\/-\/libs -\/-\/cflags ecore ecore-\/evas edje`}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifdef HAVE\_CONFIG\_H}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include "config.h"}}
\DoxyCodeLine{\textcolor{preprocessor}{\#else}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define PACKAGE\_EXAMPLES\_DIR "."}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define EINA\_UNUSED}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#ifndef PACKAGE\_DATA\_DIR}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define PACKAGE\_DATA\_DIR "."}}
\DoxyCodeLine{\textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <Ecore.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Ecore__Evas_8h}{Ecore\_Evas.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Edje_8h}{Edje.h}}>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#define WIDTH     (700)}}
\DoxyCodeLine{\textcolor{preprocessor}{\#define HEIGHT    (700)}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_delete(Ecore\_Evas *ee \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_ga95cf8e97dff0716433c2c5474d606a98}{ecore\_main\_loop\_quit}}();}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{/* mouse over signals */}}
\DoxyCodeLine{\textcolor{keyword}{static} \textcolor{keywordtype}{void}}
\DoxyCodeLine{\_on\_mouse\_over(\textcolor{keywordtype}{void} *data, \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *edje\_obj,}
\DoxyCodeLine{               \textcolor{keyword}{const} \textcolor{keywordtype}{char} *emission \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keyword}{const} \textcolor{keywordtype}{char} *source \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *evas;}
\DoxyCodeLine{   \textcolor{keywordtype}{int} x, y, mouseX, mouseY;}
\DoxyCodeLine{}
\DoxyCodeLine{   evas = (\mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *) data;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga6f52fab1a96dc58c85ee481d84bac871}{evas\_object\_geometry\_get}}(edje\_obj, \&x, \&y, NULL, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_pointer\_output\_xy\_get(evas, \&mouseX, \&mouseY);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} ((rand() \% 2) == 0)}
\DoxyCodeLine{     x += ((mouseX -\/ x) + (x / 4 + mouseY / 2));}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     x -\/= ((mouseX -\/ x) + (x / 4 + mouseY / 2));}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} ((rand() \% 2) == 0)}
\DoxyCodeLine{     y += ((mouseY -\/ y) + (y / 4 + mouseX / 2));}
\DoxyCodeLine{   \textcolor{keywordflow}{else}}
\DoxyCodeLine{     y -\/= ((mouseY -\/ y) + (y / 4 + mouseX / 2));}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (x > WIDTH)}
\DoxyCodeLine{     x = WIDTH;}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (x < 0) x = 0;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (y > HEIGHT)}
\DoxyCodeLine{     y = HEIGHT;}
\DoxyCodeLine{   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (y < 0) y = 0;}
\DoxyCodeLine{}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"Moving object to -\/ (\%d,\%d)\(\backslash\)n"}, x, y);}
\DoxyCodeLine{}
\DoxyCodeLine{   evas\_object\_move(edje\_obj, x, y);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int} argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{char} **argv \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})}
\DoxyCodeLine{\{}
\DoxyCodeLine{   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *edje\_file = PACKAGE\_DATA\_DIR\textcolor{stringliteral}{"/signalsBubble.edj"};}
\DoxyCodeLine{   Ecore\_Evas *ee;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Canvas_ga5ff87cc4ce6bc43e3b640a6d37f73043}{Evas}} *evas;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *bg;}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga9e19e6dd1f517a0ba437c0114d3e7c97}{Evas\_Object}} *edje\_obj;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Ecore__Evas__Group_ga32ddbb6457033ad435a177eb0c4fe235}{ecore\_evas\_init}}()) \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Edje__General__Group_ga1c9c6594f38023c29fbfb2d0c8c675db}{edje\_init}}()) \textcolor{keywordflow}{goto} shutdown\_ecore\_evas;}
\DoxyCodeLine{}
\DoxyCodeLine{   ee = \mbox{\hyperlink{group__Ecore__Evas__Group_gac7f2cdbcb79635c34317c1183dd04cb0}{ecore\_evas\_new}}(NULL, 0, 0, WIDTH, HEIGHT, NULL);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!ee) \textcolor{keywordflow}{goto} shutdown\_edje;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3d478e975e2101b9b821ef24baf3dd9e}{ecore\_evas\_callback\_delete\_request\_set}}(ee, \_on\_delete);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga3b2832e0373bbafae2bb7143618535c1}{ecore\_evas\_title\_set}}(ee, \textcolor{stringliteral}{"Edje animations and signals"});}
\DoxyCodeLine{}
\DoxyCodeLine{   evas = \mbox{\hyperlink{group__Ecore__Evas__Group_ga75a7cc694b6069e78df47dab0b0f2d20}{ecore\_evas\_get}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{   bg = \mbox{\hyperlink{group__Evas__Object__Rectangle_ga4d80fc32ad1cac28428cebd65d746751}{evas\_object\_rectangle\_add}}(evas);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_gae34bdcfd7f5100151f6ea8ef4a392949}{evas\_object\_color\_set}}(bg, 255, 255, 255, 255); \textcolor{comment}{//White}}
\DoxyCodeLine{   evas\_object\_move(bg, 0, 0); \textcolor{comment}{//orign}}
\DoxyCodeLine{   evas\_object\_resize(bg, WIDTH, HEIGHT); \textcolor{comment}{//cover the window}}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(bg);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gac35627a5c3a766ee42762dbcc9eb733d}{ecore\_evas\_object\_associate}}(ee, bg, ECORE\_EVAS\_OBJECT\_ASSOCIATE\_BASE);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group_ga4405e118e1fb762987af1269b6848db5}{evas\_object\_focus\_set}}(bg, \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}});}
\DoxyCodeLine{}
\DoxyCodeLine{   edje\_obj = edje\_object\_add(evas);}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{if} (!edje\_object\_file\_set(edje\_obj, edje\_file, \textcolor{stringliteral}{"image\_group"}))}
\DoxyCodeLine{     \{}
\DoxyCodeLine{        \textcolor{keywordtype}{int} err = edje\_object\_load\_error\_get(edje\_obj);}
\DoxyCodeLine{        \textcolor{keyword}{const} \textcolor{keywordtype}{char} *errmsg = edje\_load\_error\_str(err);}
\DoxyCodeLine{        fprintf(stderr, \textcolor{stringliteral}{"Could not load the edje file -\/ reason:\%s\(\backslash\)n"}, errmsg);}
\DoxyCodeLine{        \textcolor{keywordflow}{goto} shutdown\_edje;}
\DoxyCodeLine{     \}}
\DoxyCodeLine{}
\DoxyCodeLine{   edje\_object\_signal\_callback\_add(edje\_obj, \textcolor{stringliteral}{"mouse,move"}, \textcolor{stringliteral}{"part\_image"},}
\DoxyCodeLine{                                   \_on\_mouse\_over, evas);}
\DoxyCodeLine{   evas\_object\_resize(edje\_obj, 63, 63);}
\DoxyCodeLine{   evas\_object\_move(edje\_obj, 50, 50);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Evas__Object__Group__Basic_ga9cbc13661584e49fb9d9cdab514a1eeb}{evas\_object\_show}}(edje\_obj);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_ga4953047ff97d4f1b0d75a7d513d4f317}{ecore\_evas\_show}}(ee);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Main__Loop__Group_gaf103b9f668bb3e4fed12e52c6180132d}{ecore\_main\_loop\_begin}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gad3ec61f2aa03df4d3dbfd0d311e0c8dc}{ecore\_evas\_free}}(ee);}
\DoxyCodeLine{   \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();}
\DoxyCodeLine{   \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_SUCCESS;}
\DoxyCodeLine{}
\DoxyCodeLine{   shutdown\_edje: \mbox{\hyperlink{group__Edje__General__Group_ga01041f6702f2d81bf10c3e41899805cb}{edje\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   shutdown\_ecore\_evas: \mbox{\hyperlink{group__Ecore__Evas__Group_gab8fa311077f749190c9b622f672b2214}{ecore\_evas\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} EXIT\_FAILURE;}
\DoxyCodeLine{\}}
\end{DoxyCodeInclude}


To compile use this command\+: \begin{DoxyVerb}* 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
* \end{DoxyVerb}
 