

On this example we are going to have a button that when clicked will show our hover widget, this hover will have content set on it's left, top, right and middle positions. In the middle position we are placing a button that when clicked will hide the hover. We are also going to use a non-\/default theme for our hover. We won't explain the functioning of button for that see \hyperlink{group__Button}{Button}.

We start our example with a couple of callbacks that show and hide the data they're given(which we'll see later on is the hover widget)\-: 
\begin{DoxyCodeInclude}
\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_show\_hover(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   evas\_object\_show(data);
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_hide\_hover(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   evas\_object\_hide(data);
\}

\end{DoxyCodeInclude}


In our main function we'll do some initialization and then create 3 rectangles, one red, one green and one blue to use in our hover. We'll also create the 2 buttons that will show and hide the hover\-: 
\begin{DoxyCodeInclude}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *bt, *bt2, *rect, *rect2, *rect3, *hover;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add(\textcolor{stringliteral}{"hover"}, \textcolor{stringliteral}{"Hover"});
   elm_win_autodel_set(win, EINA\_TRUE);

   rect = evas\_object\_rectangle\_add(evas\_object\_evas\_get(win));
   evas\_object\_size\_hint\_min\_set(rect, 25, 25);
   evas\_object\_color\_set(rect, 255, 0, 0, 255);
   evas\_object\_show(rect);

   rect2 = evas\_object\_rectangle\_add(evas\_object\_evas\_get(win));
   evas\_object\_size\_hint\_min\_set(rect2, 25, 25);
   evas\_object\_color\_set(rect2, 0, 255, 0, 255);
   evas\_object\_show(rect2);

   rect3 = evas\_object\_rectangle\_add(evas\_object\_evas\_get(win));
   evas\_object\_size\_hint\_min\_set(rect3, 25, 25);
   evas\_object\_color\_set(rect3, 0, 0, 255, 255);
   evas\_object\_show(rect3);

   bt = elm_button_add(win);
   elm\_object\_text\_set(bt, \textcolor{stringliteral}{"Show hover"});
   evas\_object\_move(bt, 60, 90);
   evas\_object\_resize(bt, 80, 20);
   evas\_object\_show(bt);

   bt2 = elm_button_add(win);
   elm\_object\_text\_set(bt2, \textcolor{stringliteral}{"Hide hover"});
   evas\_object\_show(bt2);

\end{DoxyCodeInclude}


With all of that squared away we can now get to the heart of the matter, creating our hover widget, which is easy as pie\-: 
\begin{DoxyCodeInclude}

   hover = elm_hover_add(win);

\end{DoxyCodeInclude}


Having created our hover we now need to set the parent and target. Which if you recall from the function documentations are going to tell the hover which area it should cover and where it should be centered\-: 
\begin{DoxyCodeInclude}
   elm_hover_parent_set(hover, win);
   elm_hover_target_set(hover, bt);

\end{DoxyCodeInclude}


Now we set the theme for our hover. We're using the popout theme which gives our contents a white background and causes their appearance to be animated\-: 
\begin{DoxyCodeInclude}

   elm_object_style_set(hover, \textcolor{stringliteral}{"popout"});

\end{DoxyCodeInclude}


And finally we set the content for our positions\-: 
\begin{DoxyCodeInclude}

   elm_object_part_content_set(hover, \textcolor{stringliteral}{"left"}, rect);
   elm_object_part_content_set(hover, \textcolor{stringliteral}{"top"}, rect2);
   elm_object_part_content_set(hover, \textcolor{stringliteral}{"right"}, rect3);
   elm_object_part_content_set(hover, \textcolor{stringliteral}{"middle"}, bt2);

\end{DoxyCodeInclude}


So far so good? Great 'cause that's all there is too it, what is left now is just connecting our buttons to the callbacks we defined at the beginning of the example and run the main loop\-: 
\begin{DoxyCodeInclude}

   evas\_object\_smart\_callback\_add(bt, \textcolor{stringliteral}{"clicked"}, \_show\_hover, hover);
   evas\_object\_smart\_callback\_add(bt2, \textcolor{stringliteral}{"clicked"}, \_hide\_hover, hover);

   evas\_object\_resize(win, 200, 200);
   evas\_object\_show(win);

   elm_run();
   elm_shutdown();

   \textcolor{keywordflow}{return} 0;
\}
ELM_MAIN()

\end{DoxyCodeInclude}


Our example will initially look like this\-:

 
\begin{DoxyImage}
\includegraphics{screenshots/hover_example_01}
\caption{width=}
\end{DoxyImage}


And after you click the \char`\"{}\-Show hover\char`\"{} button it will look like this\-:

 
\begin{DoxyImage}
\includegraphics{screenshots/hover_example_01_a}
\caption{width=}
\end{DoxyImage}
 