refactor: Rename click kwarg to on_click for API consistency (closes #126)

BREAKING CHANGE: Constructor keyword argument renamed from `click` to
`on_click` for all UIDrawable types (Frame, Caption, Sprite, Grid, Line,
Circle, Arc).

Before: Frame(pos=(0,0), size=(100,100), click=handler)
After:  Frame(pos=(0,0), size=(100,100), on_click=handler)

The property name was already `on_click` - this makes the constructor
kwarg match, completing the callback naming standardization from #139.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-12-28 14:31:22 -05:00
commit c9c7375827
14 changed files with 1953 additions and 237 deletions

View file

@ -463,7 +463,7 @@ int UIArc::init(PyUIArcObject* self, PyObject* args, PyObject* kwds) {
static const char* kwlist[] = {
"center", "radius", "start_angle", "end_angle", "color", "thickness",
"click", "visible", "opacity", "z_index", "name",
"on_click", "visible", "opacity", "z_index", "name",
nullptr
};
@ -511,7 +511,7 @@ int UIArc::init(PyUIArcObject* self, PyObject* args, PyObject* kwds) {
// Handle common UIDrawable properties
if (click_handler && click_handler != Py_None) {
if (!PyCallable_Check(click_handler)) {
PyErr_SetString(PyExc_TypeError, "click must be callable");
PyErr_SetString(PyExc_TypeError, "on_click must be callable");
return -1;
}
self->data->click_register(click_handler);

View file

@ -134,7 +134,7 @@ namespace mcrfpydef {
" color (Color, optional): Arc color. Default: White\n"
" thickness (float, optional): Line thickness. Default: 1.0\n\n"
"Keyword Args:\n"
" click (callable): Click handler. Default: None\n"
" on_click (callable): Click handler. Default: None\n"
" visible (bool): Visibility state. Default: True\n"
" opacity (float): Opacity (0.0-1.0). Default: 1.0\n"
" z_index (int): Rendering order. Default: 0\n"

View file

@ -331,7 +331,7 @@ int UICaption::init(PyUICaptionObject* self, PyObject* args, PyObject* kwds)
static const char* kwlist[] = {
"pos", "font", "text", // Positional args (as per spec)
// Keyword-only args
"fill_color", "outline_color", "outline", "font_size", "click",
"fill_color", "outline_color", "outline", "font_size", "on_click",
"visible", "opacity", "z_index", "name", "x", "y",
nullptr
};

View file

@ -400,7 +400,7 @@ PyObject* UICircle::repr(PyUICircleObject* self) {
int UICircle::init(PyUICircleObject* self, PyObject* args, PyObject* kwds) {
static const char* kwlist[] = {
"radius", "center", "fill_color", "outline_color", "outline",
"click", "visible", "opacity", "z_index", "name", NULL
"on_click", "visible", "opacity", "z_index", "name", NULL
};
float radius = 10.0f;
@ -480,7 +480,7 @@ int UICircle::init(PyUICircleObject* self, PyObject* args, PyObject* kwds) {
// Handle common UIDrawable properties
if (click_obj && click_obj != Py_None) {
if (!PyCallable_Check(click_obj)) {
PyErr_SetString(PyExc_TypeError, "click must be callable");
PyErr_SetString(PyExc_TypeError, "on_click must be callable");
return -1;
}
self->data->click_register(click_obj);

View file

@ -123,7 +123,7 @@ namespace mcrfpydef {
" outline_color (Color, optional): Outline color. Default: Transparent\n"
" outline (float, optional): Outline thickness. Default: 0 (no outline)\n\n"
"Keyword Args:\n"
" click (callable): Click handler. Default: None\n"
" on_click (callable): Click handler. Default: None\n"
" visible (bool): Visibility state. Default: True\n"
" opacity (float): Opacity (0.0-1.0). Default: 1.0\n"
" z_index (int): Rendering order. Default: 0\n"

View file

@ -504,7 +504,7 @@ int UIFrame::init(PyUIFrameObject* self, PyObject* args, PyObject* kwds)
static const char* kwlist[] = {
"pos", "size", // Positional args (as per spec)
// Keyword-only args
"fill_color", "outline_color", "outline", "children", "click",
"fill_color", "outline_color", "outline", "children", "on_click",
"visible", "opacity", "z_index", "name", "x", "y", "w", "h", "clip_children", "cache_subtree",
nullptr
};

View file

@ -749,7 +749,7 @@ int UIGrid::init(PyUIGridObject* self, PyObject* args, PyObject* kwds) {
static const char* kwlist[] = {
"pos", "size", "grid_size", "texture", // Positional args (as per spec)
// Keyword-only args
"fill_color", "click", "center_x", "center_y", "zoom",
"fill_color", "on_click", "center_x", "center_y", "zoom",
"visible", "opacity", "z_index", "name", "x", "y", "w", "h", "grid_x", "grid_y",
"layers", // #150 - layers dict parameter
nullptr

View file

@ -481,7 +481,7 @@ int UILine::init(PyUILineObject* self, PyObject* args, PyObject* kwds) {
static const char* kwlist[] = {
"start", "end", "thickness", "color",
"click", "visible", "opacity", "z_index", "name",
"on_click", "visible", "opacity", "z_index", "name",
nullptr
};
@ -549,7 +549,7 @@ int UILine::init(PyUILineObject* self, PyObject* args, PyObject* kwds) {
// Handle click handler
if (click_handler && click_handler != Py_None) {
if (!PyCallable_Check(click_handler)) {
PyErr_SetString(PyExc_TypeError, "click must be callable");
PyErr_SetString(PyExc_TypeError, "on_click must be callable");
return -1;
}
self->data->click_register(click_handler);

View file

@ -119,7 +119,7 @@ namespace mcrfpydef {
" thickness (float, optional): Line thickness in pixels. Default: 1.0\n"
" color (Color, optional): Line color. Default: White\n\n"
"Keyword Args:\n"
" click (callable): Click handler. Default: None\n"
" on_click (callable): Click handler. Default: None\n"
" visible (bool): Visibility state. Default: True\n"
" opacity (float): Opacity (0.0-1.0). Default: 1.0\n"
" z_index (int): Rendering order. Default: 0\n"

View file

@ -392,7 +392,7 @@ int UISprite::init(PyUISpriteObject* self, PyObject* args, PyObject* kwds)
static const char* kwlist[] = {
"pos", "texture", "sprite_index", // Positional args (as per spec)
// Keyword-only args
"scale", "scale_x", "scale_y", "click",
"scale", "scale_x", "scale_y", "on_click",
"visible", "opacity", "z_index", "name", "x", "y", "snapshot",
nullptr
};