

For this example we are going to assume knowledge of evas smart callbacks and some basic evas object functions. Elementary is not meant to be used without evas, if you're not yet familiar with evas it probably is worth checking that out.

And now to the example, when using Elementary we start by including Elementary.\-h\-: 
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#include <Elementary.h>}

\end{DoxyCodeInclude}


Next we define some callbacks, they all share the same signature because they are all to be used with evas\-\_\-object\-\_\-smart\-\_\-callback\-\_\-add(). The first one just prints the selected label(in two different ways)\-: 
\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{void} \_pos\_selected\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   printf(\textcolor{stringliteral}{"Selection: %s\(\backslash\)n"}, (\textcolor{keywordtype}{char} *)event\_info);
   printf(\textcolor{stringliteral}{"Label selected: %s\(\backslash\)n"}, elm_actionslider_selected_label_get(obj));
\}

\end{DoxyCodeInclude}


This next callback is a little more interesting, it makes the selected label magnetic(except if it's the center label)\-: 
\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_position\_change\_magnetic\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object * obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordflow}{if} (!strcmp((\textcolor{keywordtype}{char} *)event\_info, \textcolor{stringliteral}{"left"}))
     elm_actionslider_magnet_pos_set(obj, ELM\_ACTIONSLIDER\_LEFT);
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp((\textcolor{keywordtype}{char} *)event\_info, \textcolor{stringliteral}{"right"}))
     elm_actionslider_magnet_pos_set(obj, ELM\_ACTIONSLIDER\_RIGHT);
\}

\end{DoxyCodeInclude}


This callback enables or disables the magnetic property of the center label\-: 
\begin{DoxyCodeInclude}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
\_magnet\_enable\_disable\_cb(\textcolor{keywordtype}{void} *data, Evas\_Object *obj, \textcolor{keywordtype}{void} *event\_info)
\{
   \textcolor{keywordflow}{if} (!strcmp((\textcolor{keywordtype}{char} *)event\_info, \textcolor{stringliteral}{"left"}))
     elm_actionslider_magnet_pos_set(obj, ELM\_ACTIONSLIDER\_CENTER);
   \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (!strcmp((\textcolor{keywordtype}{char} *)event\_info, \textcolor{stringliteral}{"right"}))
     elm_actionslider_magnet_pos_set(obj, ELM\_ACTIONSLIDER\_NONE);
\}

\end{DoxyCodeInclude}


And finally a callback to stop the main loop when the window is closed\-: 
\begin{DoxyCodeInclude}

EAPI\_MAIN \textcolor{keywordtype}{int}
elm\_main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   Evas\_Object *win, *bx, *as;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

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

   bx = elm_box_add(win);
   evas\_object\_size\_hint\_weight\_set(bx, EVAS\_HINT\_EXPAND, 0);
   elm_win_resize_object_add(win, bx);
   evas\_object\_show(bx);

   as = elm_actionslider_add(win);
   evas\_object\_size\_hint\_weight\_set(as, EVAS\_HINT\_EXPAND, 0);
   evas\_object\_size\_hint\_align\_set(as, EVAS\_HINT\_FILL, 0);
   elm_actionslider_indicator_pos_set(as, ELM\_ACTIONSLIDER\_RIGHT);
   elm_actionslider_magnet_pos_set(as, ELM\_ACTIONSLIDER\_RIGHT);
   elm_object_part_text_set(as, \textcolor{stringliteral}{"left"}, \textcolor{stringliteral}{"Snooze"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"right"}, \textcolor{stringliteral}{"Stop"});
   elm_actionslider_enabled_pos_set(as, ELM\_ACTIONSLIDER\_LEFT |
                                    ELM\_ACTIONSLIDER\_RIGHT);
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"pos\_changed"},
                                  \_position\_change\_magnetic\_cb, NULL);
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"selected"}, \_pos\_selected\_cb, NULL);
   evas\_object\_show(as);
   elm_box_pack_end(bx, as);

   as = elm_actionslider_add(win);
   evas\_object\_size\_hint\_weight\_set(as, EVAS\_HINT\_EXPAND, 0);
   evas\_object\_size\_hint\_align\_set(as, EVAS\_HINT\_FILL, 0);
   elm_actionslider_indicator_pos_set(as, ELM\_ACTIONSLIDER\_CENTER);
   elm_actionslider_magnet_pos_set(as, ELM\_ACTIONSLIDER\_CENTER);
   elm_object_part_text_set(as, \textcolor{stringliteral}{"left"}, \textcolor{stringliteral}{"Snooze"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"right"}, \textcolor{stringliteral}{"Stop"});
   elm_actionslider_enabled_pos_set(as, ELM\_ACTIONSLIDER\_LEFT |
                                    ELM\_ACTIONSLIDER\_RIGHT);
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"selected"}, \_pos\_selected\_cb, NULL);
   evas\_object\_show(as);
   elm_box_pack_end(bx, as);

   as = elm_actionslider_add(win);
   elm_object_style_set(as, \textcolor{stringliteral}{"bar"});
   evas\_object\_size\_hint\_weight\_set(as, EVAS\_HINT\_EXPAND, 0);
   evas\_object\_size\_hint\_align\_set(as, EVAS\_HINT\_FILL, 0);
   elm_actionslider_indicator_pos_set(as, ELM\_ACTIONSLIDER\_LEFT);
   elm_actionslider_magnet_pos_set(as, ELM\_ACTIONSLIDER\_CENTER|
                                   ELM\_ACTIONSLIDER\_RIGHT);
   elm_actionslider_enabled_pos_set(as, ELM\_ACTIONSLIDER\_CENTER |
                                    ELM\_ACTIONSLIDER\_RIGHT);
   elm_object_part_text_set(as, \textcolor{stringliteral}{"center"}, \textcolor{stringliteral}{"Accept"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"right"}, \textcolor{stringliteral}{"Reject"});
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"selected"}, \_pos\_selected\_cb, NULL);
   evas\_object\_show(as);
   elm_box_pack_end(bx, as);

   as = elm_actionslider_add(win);
   elm_object_style_set(as, \textcolor{stringliteral}{"bar"});
   evas\_object\_size\_hint\_weight\_set(as, EVAS\_HINT\_EXPAND, 0);
   evas\_object\_size\_hint\_align\_set(as, EVAS\_HINT\_FILL, 0);
   elm_actionslider_indicator_pos_set(as, ELM\_ACTIONSLIDER\_LEFT);
   elm_actionslider_magnet_pos_set(as, ELM\_ACTIONSLIDER\_LEFT);
   elm_object_part_text_set(as, \textcolor{stringliteral}{"center"}, \textcolor{stringliteral}{"Accept"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"right"}, \textcolor{stringliteral}{"Reject"});
   elm\_object\_text\_set(as, \textcolor{stringliteral}{"Go"});
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"pos\_changed"},
                                  \_position\_change\_magnetic\_cb, NULL);
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"selected"}, \_pos\_selected\_cb, NULL);
   evas\_object\_show(as);
   elm_box_pack_end(bx, as);


   as = elm_actionslider_add(win);
   evas\_object\_size\_hint\_weight\_set(as, EVAS\_HINT\_EXPAND, 0);
   evas\_object\_size\_hint\_align\_set(as, EVAS\_HINT\_FILL, 0);
   elm_actionslider_indicator_pos_set(as, ELM\_ACTIONSLIDER\_LEFT);
   elm_actionslider_magnet_pos_set(as, ELM\_ACTIONSLIDER\_ALL);
   elm_object_part_text_set(as, \textcolor{stringliteral}{"left"}, \textcolor{stringliteral}{"Left"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"center"}, \textcolor{stringliteral}{"Center"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"right"}, \textcolor{stringliteral}{"Right"});
   elm\_object\_text\_set(as, \textcolor{stringliteral}{"Go"});
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"selected"}, \_pos\_selected\_cb, NULL);
   evas\_object\_show(as);
   elm_box_pack_end(bx, as);

   as = elm_actionslider_add(win);
   evas\_object\_size\_hint\_weight\_set(as, EVAS\_HINT\_EXPAND, 0);
   evas\_object\_size\_hint\_align\_set(as, EVAS\_HINT\_FILL, 0);
   elm_actionslider_indicator_pos_set(as, ELM\_ACTIONSLIDER\_CENTER);
   elm_actionslider_magnet_pos_set(as, ELM\_ACTIONSLIDER\_CENTER);
   elm_object_part_text_set(as, \textcolor{stringliteral}{"left"}, \textcolor{stringliteral}{"Enable"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"center"}, \textcolor{stringliteral}{"Magnet"});
   elm_object_part_text_set(as, \textcolor{stringliteral}{"right"}, \textcolor{stringliteral}{"Disable"});
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"pos\_changed"},
                                  \_magnet\_enable\_disable\_cb, NULL);
   evas\_object\_smart\_callback\_add(as, \textcolor{stringliteral}{"selected"}, \_pos\_selected\_cb, NULL);
   evas\_object\_show(as);
   elm_box_pack_end(bx, as);

   evas\_object\_resize(win, 320, 400);
   evas\_object\_show(win);

   elm_run();
   elm_shutdown();
   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}


To be able to create our actionsliders we need to do some setup, but this isn't really relevant here, so if you want to know about that go \hyperlink{group__Win}{here}.

With all that boring stuff out of the way we can proceed to creating some actionsliders.\par
All actionsliders are created the same way\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}
 Next we must choose where the indicator starts, and for this one we choose the right, and set the right as magnetic\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


We then set the labels for the left and right, passing N\-U\-L\-L as an argument to any of the labels makes that position have no label. 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Furthermore we mark both left and right as enabled positions, if we didn't do this all three positions would be enabled\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


Having the enabled positions we now add a smart callback to change which position is magnetic, so that only the last selected position is magnetic\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


And finally we set our printing callback and show the actionslider\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


For our next actionslider we are going to do much as we did for the previous except we are going to have the center as the magnet(and not change it)\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


And another actionslider, in this one the indicator starts on the left. It has labels only in the center and right, and both positions are magnetic. Because the left doesn't have a label and is not magnetic once the indicator leaves it can't return\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
The greyed out area is a \hyperlink{group__Styles}{style}.
\end{DoxyNote}
And now an actionslider with a label in the indicator, and whose magnet properties change based on what was last selected\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
The greyed out area is a \hyperlink{group__Styles}{style}.
\end{DoxyNote}
We are almost done, this next one is just an actionslider with all positions magnetized and having every possible label\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


And for our last actionslider we have one that turns the magnetic property on and off\-: 
\begin{DoxyCodeInclude}

\end{DoxyCodeInclude}


The example will look like this\-:

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


See the full source code \hyperlink{actionslider_example_01}{here} 