Issues with manipulation events
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" );
}
};
Re: Issues with manipulation events
The class should be registered with the rest of classes. Once it is registered it should be automatically created by the XAML. Please, check that before.
Re: Issues with manipulation events
Thanks for your response
I've registered the component
NsRegisterComponent< InfoPanelTouch >();
But I'm still not getting break points in any of the events when touching the UI
Also Transform2f is not recognized (incomplete type ), even though I've included Rect.h
I've registered the component
NsRegisterComponent< InfoPanelTouch >();
But I'm still not getting break points in any of the events when touching the UI
Also Transform2f is not recognized (incomplete type ), even though I've included Rect.h
Re: Issues with manipulation events
Is the class being created? Could you put a breakpoint in the ctor? Besides, I recommend adding the c++ keyword override just to make sure you are overriding the proper functions.But I'm still not getting break points in any of the events when touching the UI
Not sure, to be following here, because if you are not able to compile previous comments make not sense. Transform2f is declated in "NsMath/Transform.h"Also Transform2f is not recognized (incomplete type ), even though I've included Rect.h
Re: Issues with manipulation events
There is a sample inside the C++ SDK, Touch, doing something similar to what you want to achieve. Could you please also try it? Thanks!
Re: Issues with manipulation events
Thanks, I took a look at the code in the sdk and made some changes. Now I'm getting the events
However, when trying to translate the rendertransform, nothing happens.
Any ideas what could prevent the translation?
However, when trying to translate the rendertransform, nothing happens.
Any ideas what could prevent the translation?
Code: Select all
void cMainWindow::OnManipulationDelta( const Noesis::ManipulationDeltaEventArgs& e )
{
Noesis::UIElement* info_panel = ( Noesis::UIElement* )e.source;
Noesis::MatrixTransform* transform = ( Noesis::MatrixTransform* )info_panel->GetRenderTransform();
Noesis::Transform2f matrix = transform->GetMatrix();
matrix.Translate( 0.0f, e.deltaManipulation.translation.y );
transform->SetMatrix( matrix );
e.handled = true;
}
Code: Select all
<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">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform Y="{Binding ActualHeight, ElementName=PanelMiddle_offset}"/>
</TransformGroup>
</Grid.RenderTransform>
<Border BorderBrush="{DynamicResource UIBrush_Border}" BorderThickness="4,4,4,0" CornerRadius="16,16,0,0" Background="{DynamicResource UIBrush_Primary}"/>
<StackPanel x:Name="infoPanelEverything" Margin="0" Orientation="Vertical">
<Grid x:Name="InfoPanel_Touch" Height="{Binding ActualHeight, ElementName=PanelTop_height}" Margin="0" VerticalAlignment="Top" Background="#00000000">
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Viewbox HorizontalAlignment="Center" Grid.Row="1">
<Border Background="{DynamicResource UIBrush_Border}" Width="142" CornerRadius="8" BorderThickness="0" Height="16"/>
</Viewbox>
</Grid>
<Viewbox Margin="16,0">
<StackPanel x:Name="Infopanel_Content" RenderTransformOrigin="0.5,0.5" Width="468.706">
<StackPanel.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</StackPanel.RenderTransform>
<!--....-->
</StackPanel>
</Viewbox>
</StackPanel>
</Grid>
-
sfernandez
Site Admin
- Posts: 2995
- Joined:
Re: Issues with manipulation events
Looking at the xaml I see what was the problem. InfoPanel grid has a TransformGroup as RenderTransform, but you are casting to MatrixTransform.
You have to cast to TransformGroup and get the TranslateTransform from the Children to update the vertical offset.
Although if you only want to translate that element it would be even better if you just have a TranslateTransform as RenderTransform:
You have to cast to TransformGroup and get the TranslateTransform from the Children to update the vertical offset.
Although if you only want to translate that element it would be even better if you just have a TranslateTransform as RenderTransform:
Code: Select all
<Grid x:Name="InfoPanel" ...>
<Grid.RenderTransform>
<TranslateTransform />
</Grid.RenderTransform>
...
</Grid>
Code: Select all
void cMainWindow::OnManipulationDelta( const Noesis::ManipulationDeltaEventArgs& e )
{
Noesis::UIElement* info_panel = ( Noesis::UIElement* )e.source;
Noesis::TranslateTransform* transform = ( Noesis::TranslateTransform* )info_panel->GetRenderTransform();
transform->SetY(transform->GetY() + e.deltaManipulation.translation.y);
e.handled = true;
}
Who is online
Users browsing this forum: Ahrefs [Bot] and 4 guests