Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bindings/interface/ScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PyBScrollBar : public BScrollBar{
PYBIND11_OVERLOAD(void, BScrollBar, FrameMoved, new_position);
}
void FrameResized(float newWidth, float newHeight) override {
PYBIND11_OVERLOAD(void, BScrollBar, FrameResized, newWidth, newWidth);
PYBIND11_OVERLOAD(void, BScrollBar, FrameResized, newWidth, newHeight);
}
void MessageReceived(BMessage* message) override {
PYBIND11_OVERLOAD(void, BScrollBar, MessageReceived, message);
Expand Down
56 changes: 56 additions & 0 deletions tests/scrollBarFrameResized.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from Be import BApplication, BRect, BScrollBar, B_HORIZONTAL


EXPECTED_CALLBACKS = [
(123.5, 45.25),
]


class CallbackProbe(BScrollBar):
def __init__(self):
BScrollBar.__init__(
self,
BRect(0.0, 0.0, 100.0, 20.0),
"frame-resized-probe",
None,
0.0,
100.0,
B_HORIZONTAL,
)

self.calls = []

def FrameResized(self, new_width, new_height):
self.calls.append((new_width, new_height))


def main():
application = BApplication(
"application/x-vnd.haiku-pyapi-"
"scrollbar-frame-resized-test"
)

scroll_bar = CallbackProbe()

# Enter the C++ virtual trampoline through the bound
# base method instead of calling the Python override directly.
BScrollBar.FrameResized(scroll_bar, 123.5, 45.25)

if scroll_bar.calls != EXPECTED_CALLBACKS:
raise SystemExit(
"FAIL: incorrect BScrollBar FrameResized "
f"callback arguments: {scroll_bar.calls!r}"
)

print("callbacks =", scroll_bar.calls)
print(
"BSCROLLBAR FRAMERESIZED CALLBACK "
"REGRESSION TEST: PASS"
)

del scroll_bar
del application


if __name__ == "__main__":
main()