Greeting,
I m new to Urho 3d, I am migrating from other c++ game engine to urho3d, But I have a difficulties to handle the scroll view.
_Questions: - _
1. It only render the element which within the size, when scroll down, it is empty
2. How do I listen the scroll view event(onMove, onSlide .etc)
This is my sample code below, but i
_scrollV = GetSubsystem<UI>()->GetRoot()->CreateChild<ScrollView>();
_scrollV->SetStyleAuto();
_scrollV->SetSize(GetSubsystem<UI>()->GetRoot()->GetWidth()/2, GetSubsystem<UI>()->GetRoot()->GetHeight()/3);
_scrollV->SetPosition(0, 0);
_scrollV->SetPriority(100);
_scrollV->SetColor(Color::BLACK);
_scrollV->SetEnabled(true);
_scrollV->SetDeepEnabled(true);
_scrollV->SetSelected(true);
_scrollV->SetHovering(true);
_scrollV->SetScrollBarsVisible(true, true);
SharedPtr<Urho3D::UIElement> chatContentElement(_scrollV->CreateChild<Urho3D::UIElement>());
_scrollV->SetContentElement(chatContentElement);
chatContentElement->SetLayoutMode(Urho3D::LM_VERTICAL);
chatContentElement->SetStyleAuto();
chatContentElement->SetPosition(0, 0);
chatContentElement->SetAlignment(Urho3D::HA_LEFT, Urho3D::VA_BOTTOM);
chatContentElement->SetSize(_scrollV->GetSize());
for(int i=20;i>0;i--) {
// Construct new Text object
SharedPtr<Text> helloText(new Text(context_));
// Set String to display
helloText->SetText("Hello World from Urho3D Hello World from Urho3D Hello World from Urho3D Hello World from Urho3D Hello World from Urho3D ");
// Set font and text color
helloText->SetFont(cache->GetResource<Font>("Fonts/Anonymous Pro.sdf"), GetSubsystem<UI>()->GetRoot()->GetMaxWidth());
helloText->SetColor(Color::GREEN);
helloText->SetPosition(0 , GetSubsystem<UI>()->GetRoot()->GetHeight() * (i/20) );
helloText->SetPriority(100);
_scrollV->GetContentElement()->AddChild(helloText);
}
SubscribeToEvent(_scrollV, E_MOUSEBUTTONDOWN, URHO3D_HANDLER(HelloWorld, HandleScrollUpdate) );