Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
Callback functions from Kodi to add-on

Detailed Description

GUI window callback functions.
Functions to handle control callbacks from Kodi


Go back to normal functions from CWindow

Function Documentation

◆ OnInit()

virtual bool OnInit ( )
inlinevirtual

OnInit method.

Returns
Return true if initialize was done successful

◆ OnFocus()

virtual bool OnFocus ( int controlId)
inlinevirtual

OnFocus method.

Parameters
[in]controlIdGUI control identifier
Returns
Return true if focus condition was handled there or false to handle them by Kodi itself

◆ OnClick()

virtual bool OnClick ( int controlId)
inlinevirtual

OnClick method.

Parameters
[in]controlIdGUI control identifier
Returns
Return true if click was handled there or false to handle them by Kodi itself

◆ OnAction()

virtual bool OnAction ( ADDON_ACTION actionId)
inlinevirtual

OnAction method.

Parameters
[in]actionIdThe action id to perform, see kodi_key_action_ids to get list of them
Returns
Return true if action was handled there or false to handle them by Kodi itself

This method will receive all actions that the main program will send to this window.

Note
  • By default, only the ADDON_ACTION_PREVIOUS_MENU and ADDON_ACTION_NAV_BACK actions are handled.
  • Overwrite this method to let your code handle all actions.
  • Don't forget to capture ADDON_ACTION_PREVIOUS_MENU or ADDON_ACTION_NAV_BACK, else the user can't close this window.

Example:

..
// Window used with parent / child way
bool cYOUR_CLASS::OnAction(ADDON_ACTION actionId)
{
switch (action)
{
printf("action received: previous");
Close();
return true;
printf("action received: show info");
break;
printf("action received: stop");
break;
printf("action received: pause");
break;
default:
break;
}
return false;
}
..
ADDON_ACTION
Definition action_ids.h:19
@ ADDON_ACTION_PREVIOUS_MENU
10: Previous menu.
Definition action_ids.h:54
@ ADDON_ACTION_NAV_BACK
90: Nav back.
Definition action_ids.h:286
@ ADDON_ACTION_SHOW_INFO
11: Show info.
Definition action_ids.h:57
@ ADDON_ACTION_STOP
13: Stop.
Definition action_ids.h:63
@ ADDON_ACTION_PAUSE
12: Pause.
Definition action_ids.h:60
void Close()
Closes this window.
Definition Window.h:183

◆ GetContextButtons()

virtual void GetContextButtons ( int itemNumber,
std::vector< std::pair< unsigned int, std::string > > & buttons )
inlinevirtual

Get context menu buttons for list entry.

Parameters
[in]itemNumberSelected list item entry
[in]buttonsList where context menus becomes added with his identifier and name

◆ OnContextButton()

virtual bool OnContextButton ( int itemNumber,
unsigned int button )
inlinevirtual

Called after selection in context menu.

Parameters
[in]itemNumberSelected list item entry
[in]buttonThe pressed button id
Returns
true if handled, otherwise false

◆ SetIndependentCallbacks()

void SetIndependentCallbacks ( kodi::gui::ClientHandle cbhdl,
bool(* CBOnInit )(kodi::gui::ClientHandle cbhdl),
bool(* CBOnFocus )(kodi::gui::ClientHandle cbhdl, int controlId),
bool(* CBOnClick )(kodi::gui::ClientHandle cbhdl, int controlId),
bool(* CBOnAction )(kodi::gui::ClientHandle cbhdl, ADDON_ACTION actionId),
void(* CBGetContextButtons )(kodi::gui::ClientHandle cbhdl, int itemNumber, gui_context_menu_pair *buttons, unsigned int *size) = nullptr,
bool(* CBOnContextButton )(kodi::gui::ClientHandle cbhdl, int itemNumber, unsigned int button) = nullptr )
inline

Set independent callbacks

If the class is used independent (with "new CWindow") and not as parent (with "cCLASS_own : public kodi::gui::CWindow") from own must be the callback from Kodi to add-on overdriven with own functions!

Parameters
[in]cbhdlThe pointer to own handle data structure / class
[in]CBOnInitOwn defined window init function
[in]CBOnFocusOwn defined focus function
[in]CBOnClickOwn defined click function
[in]CBOnActionOwn defined action function
[in]CBGetContextButtons[opt] To get context menu entries for lists function
[in]CBOnContextButton[opt] Used context menu entry function

Example:

...
{
...
return true;
}
bool OnFocus(kodi::gui::ClientHandle cbhdl, int controlId)
{
...
return true;
}
bool OnClick(kodi::gui::ClientHandle cbhdl, int controlId)
{
...
return true;
}
{
...
return true;
}
...
// Somewhere where you create the window
CWindow myWindow = new CWindow;
myWindow->SetIndependentCallbacks(myWindow, OnInit, OnFocus, OnClick, OnAction);
...
KODI_GUI_CLIENT_HANDLE ClientHandle
Handler for addon-sided processing class If the callback functions used by the window are not used di...
Definition Window.h:43
virtual bool OnAction(ADDON_ACTION actionId)
OnAction method.
Definition Window.h:740
virtual bool OnInit()
OnInit method.
Definition Window.h:661
virtual bool OnFocus(int controlId)
OnFocus method.
Definition Window.h:673
virtual bool OnClick(int controlId)
OnClick method.
Definition Window.h:685
CWindow(const std::string &xmlFilename, const std::string &defaultSkin, bool asDialog, bool isMedia=false)
Class constructor with needed values for window / dialog.
Definition Window.h:126