Closed wimstockman closed 1 year ago
Hi Wim, it's generally intended that the child adding order determines the tab order. But you can change the order afterward (for example, by sorting the children's list).
#include <final/final.h>
using namespace finalcut;
int main (int argc, char* argv[])
{
FApplication app(argc, argv);
// The dialog window
FDialog dialog("The window title", &app);
dialog.setGeometry (FPoint{20, 5}, FSize{40, 12});
// The child objects from dialog
FButton child4("&4", &dialog); // 1st child
FButton child1("&1", &dialog); // 2nd child
FButton child3("&3", &dialog); // 3rd child
FButton child2("&2", &dialog); // 4th child
child1.setGeometry(FPoint{6, 2}, FSize{28, 1});
child2.setGeometry(FPoint{6, 4}, FSize{28, 1});
child3.setGeometry(FPoint{6, 6}, FSize{28, 1});
child4.setGeometry(FPoint{6, 8}, FSize{28, 1});
// Sort by button name to change the initial tab order of the widgets
std::sort ( dialog.begin()
, dialog.end()
, [] (const auto lhs, const auto rhs)
{
// Skip non-button widgets
if ( ! lhs->isInstanceOf("FButton")
|| ! rhs->isInstanceOf("FButton") )
return false;
const auto& lhs_btn = static_cast<FButton*>(lhs);
const auto& rhs_btn = static_cast<FButton*>(rhs);
return lhs_btn->getText() < rhs_btn->getText();
} );
FWidget::setMainWidget(&dialog);
dialog.show();
return app.exec();
}
Hi gansm,
Thanks for this example. Just what I needed.
Hi , I was wondering how I can change the taborder of the nextchild focus. Kind Regards Wim