Has anybody hooked the mouse-button events?
I see that Markup's XTPMarkupInputElement.h contain the following events
static CXTPMarkupRoutedEvent* m_pMouseLeaveEvent; static CXTPMarkupRoutedEvent* m_pMouseEnterEvent; static CXTPMarkupRoutedEvent* m_pMouseLeftButtonUpEvent; static CXTPMarkupRoutedEvent* m_pMouseLeftButtonDownEvent; static CXTPMarkupRoutedEvent* m_pMouseRightButtonUpEvent; static CXTPMarkupRoutedEvent* m_pMouseRightButtonDownEvent; static CXTPMarkupRoutedEvent* m_pMouseMoveEvent; static CXTPMarkupRoutedEvent* m_pLostMouseCaptureEvent;
I also see that the MarkupPad-sample contain handlers for the Markup tags like MouseEnter and MouseLeave in found DynamicMarkup.xaml.
The markup looks like this in DynamicMarkup.xaml: <Border Grid.Column="4" Background="Magenta"><TextBlock MouseEnter="SetText1" MouseLeave="SetText2" Padding="4" Text="Column 5"/></Border>
Note the "SetText1" and "SetText2". Further, in the MarkupPad-samples CMarkupPadView::CMarkupPadView(), you find the connection between the markup's SetText1 and SetText2 like:
SetDelegate(L"SetText1", CreateMarkupClassDelegate(this, &CMarkupPadView::OnSetText1)); SetDelegate(L"SetText2", CreateMarkupClassDelegate(this, &CMarkupPadView::OnSetText2));
This allows MarkupPad's own implementation to hook into the Markup tag's *attribute values* of SetText1 and SetText2. Below you see the handler for SetText1:
void CMarkupPadView::OnSetText1(CXTPMarkupObject* pSender, CXTPMarkupMouseEventArgs* /*pArgs*/) { ((CXTPMarkupTextBlock*)pSender)->SetText(L"New Text"); }
The only challenge with this approach, is that the SetText1 now can be used in many Markup tag' attribute value, like for example:
<Border Grid.Column="4" Background="Magenta"><TextBlock MouseRightButtonUp="SetText1" MouseLeftButtonUp="SetText2" Padding="4" Text="Column 5"/></Border>
I would rather like to have a generic hook into the MouseLeft/RightButtonUp, and then for example check the Markup-tag's Tag-attribute.
Has anybody done something along these lines?
------------- Best regards,
Bob
Proud Programmer!
|