Issues with manipulation events
Posted: 12 Sep 2019, 11:46
I'm trying to let users translate an object by touch but It's not quite working.
Do I need to create an instance of the class or register it somehow? What am i missing?
Xaml
c++
Do I need to create an instance of the class or register it somehow? What am i missing?
Xaml
Code: Select all
<Grid x:Name="InfoPanel_LayoutRoot" x:Class="cInfoPanelTouch">
...
<Canvas Grid.Column="1" Grid.RowSpan="3" VerticalAlignment="Top">
<Grid x:Name="InfoPanel"
VerticalAlignment="Top"
RenderTransformOrigin="0.5,0.5"
Width="{Binding ActualWidth, ElementName=Panel_width}"
MinHeight="{Binding ActualHeight, ElementName=InfoPanel_LayoutRoot}"
IsManipulationEnabled="true">
....
Code: Select all
class cInfoPanelTouch : public Noesis::Grid
{
public:
void OnManipulationStarting( const Noesis::ManipulationStartingEventArgs& e )
{
e.mode = Noesis::ManipulationModes_Translate;
e.manipulationContainer = ( Noesis::Visual* )FindName( "InfoPanel_LayoutRoot" );
e.handled = true;
}
void OnManipulationInertiaStarting( const Noesis::ManipulationInertiaStartingEventArgs& e )
{
e.translationBehavior.desiredDeceleration = 100.0f / ( 1000.0f * 1000.0f );
e.handled = true;
}
void OnManipulationDelta( const Noesis::ManipulationDeltaEventArgs& e )
{
Noesis::UIElement* element = ( UIElement* )e.source;
Noesis::MatrixTransform* transform = ( Noesis::MatrixTransform* )element->GetRenderTransform();
Noesis::Transform2f matrix = transform->GetMatrix();
matrix.Translate( 0.0f, e.deltaManipulation.translation.y );
transform->SetMatrix( matrix );
e.handled = true;
}
private:
NS_IMPLEMENT_INLINE_REFLECTION( cInfoPanelTouch, Noesis::Grid )
{
NsMeta<Noesis::TypeId>( "cInfoPanelTouch" );
}
};