Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
Callback functions from Kodi to add-on

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

Functions

virtual bool kodi::gui::CWindow::OnInit ()
 OnInit method.
 
virtual bool kodi::gui::CWindow::OnFocus (int controlId)
 OnFocus method.
 
virtual bool kodi::gui::CWindow::OnClick (int controlId)
 OnClick method.
 
virtual bool kodi::gui::CWindow::OnAction (ADDON_ACTION actionId)
 OnAction method.
 
virtual void kodi::gui::CWindow::GetContextButtons (int itemNumber, std::vector< std::pair< unsigned int, std::string > > &buttons)
 Get context menu buttons for list entry.
 
virtual bool kodi::gui::CWindow::OnContextButton (int itemNumber, unsigned int button)
 Called after selection in context menu.
 
void kodi::gui::CWindow::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)
 Set independent callbacks
 

Detailed Description

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


Go back to normal functions from CWindow

Function Documentation

◆ GetContextButtons()

virtual void kodi::gui::CWindow::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

◆ OnAction()

virtual bool kodi::gui::CWindow::OnAction ( ADDON_ACTION actionId)
inlinevirtual

OnAction method.

Parameters
[in]actionIdThe action id to perform, see Action Id's 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 addons/kodi-dev-kit/include/kodi/gui/Window.h:183

◆ OnClick()

virtual bool kodi::gui::CWindow::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

◆ OnContextButton()

virtual bool kodi::gui::CWindow::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

◆ OnFocus()

virtual bool kodi::gui::CWindow::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

◆ OnInit()

virtual bool kodi::gui::CWindow::OnInit ( )
inlinevirtual

OnInit method.

Returns
Return true if initialize was done successful

◆ SetIndependentCallbacks()

void kodi::gui::CWindow::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);
...
friend class CWindow
Definition addons/kodi-dev-kit/include/kodi/gui/ListItem.h:40
KODI_GUI_CLIENT_HANDLE ClientHandle
Handler for addon-sided processing class If the callback functions used by the window are not used di...
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:43
virtual bool OnClick(int controlId)
OnClick method.
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:685
virtual bool OnAction(ADDON_ACTION actionId)
OnAction method.
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:740
virtual bool OnInit()
OnInit method.
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:661
virtual bool OnFocus(int controlId)
OnFocus method.
Definition addons/kodi-dev-kit/include/kodi/gui/Window.h:673