Hi,
iam showing XML in wx.stc.StyledTextCtrl, when user clicks inside the tag(), i need to move the caret out side of the tag or move the caret to end of that tag lilne like in xml copy editor(lock tag).
I tried with SetCurrentPos(pos), LineEnd(), Home(), SetInsertionPoint(0), and GotoPos(0) but the caret is not moving but xml text is selecting from the current caret position to given position.
any solution please.
Since you didn’t post code, I am assuming you’re doing this in EVT_MOUSE_DOWN, if so, try it in EVT_MOUSE_UP
···
On Sunday, October 26, 2014 6:27:32 PM UTC-7, Nagarajan Babu wrote:
Hi,
iam showing XML in wx.stc.StyledTextCtrl, when user clicks inside the tag(), i need to move the caret out side of the tag or move the caret to end of that tag lilne like in xml copy editor(lock tag).
I tried with SetCurrentPos(pos), LineEnd(), Home(), SetInsertionPoint(0), and GotoPos(0) but the caret is not moving but xml text is selecting from the current caret position to given position.
any solution please.
Here is the sample code.
self.styledTxtCtrl = stc.StyledTextCtrl(self.panel)
self.styledTxtCtrl .SetText("<some_tag>tag content</some_tag>")
self.styledTxtCtrl .Bind(wx.EVT_LEFT_UP, self.ApplyLockTag)
def ApplyLockTag(self, e):
self.styledTxtCtrl .GotoPos(self.styledTxtCtrl .GetText().find('!', self.styledTxtCtrl .GetInsertionPoint())+1)
e.Skip()
now if i click inside the tag(<some_tag> or (</some_tag>), i need to move the caret to tag content when mouse up. Right now the caret not moving but instead the text is selected till the given position.
···
On Tuesday, October 28, 2014 1:15:25 AM UTC+5:30, Nathan McCorkle wrote:
Since you didn’t post code, I am assuming you’re doing this in EVT_MOUSE_DOWN, if so, try it in EVT_MOUSE_UP
On Sunday, October 26, 2014 6:27:32 PM UTC-7, Nagarajan Babu wrote:
Hi,
iam showing XML in wx.stc.StyledTextCtrl, when user clicks inside the tag(), i need to move the caret out side of the tag or move the caret to end of that tag lilne like in xml copy editor(lock tag).
I tried with SetCurrentPos(pos), LineEnd(), Home(), SetInsertionPoint(0), and GotoPos(0) but the caret is not moving but xml text is selecting from the current caret position to given position.
any solution please.
Try wrapping the GotoPos call with wx.CallAfter
···
On Tuesday, October 28, 2014 1:50:45 AM UTC-7, Nagarajan Babu wrote:
Here is the sample code.
self.styledTxtCtrl = stc.StyledTextCtrl(self.panel)
self.styledTxtCtrl .SetText("<some_tag>tag content</some_tag>")
self.styledTxtCtrl .Bind(wx.EVT_LEFT_UP, self.ApplyLockTag)
def ApplyLockTag(self, e):
self.styledTxtCtrl .GotoPos(self.styledTxtCtrl .GetText().find('!', self.styledTxtCtrl .GetInsertionPoint())+1)
e.Skip()
now if i click inside the tag(<some_tag> or (</some_tag>), i need to move the caret to tag content when mouse up. Right now the caret not moving but instead the text is selected till the given position.