wxTextCtrl - Ctrl+A

BlitzMax Modules Forums/Brucey's Modules/wxTextCtrl - Ctrl+A

How do I get a textctrl to select everything in the textctrl using ctrl+a??

It seems that ctrl-A (select all) is not the standard functionality of a textctrl on Windows.

As an example, open Notepad, open the Find dialog, type some text in it and then try using ctrl-A. :-p

Anyways, here's a little example to show how one might enable that functionality yourself :
SuperStrict

Framework wx.wxApp
Import wx.wxFrame
Import wx.wxTextCtrl

New MyApp.run()

Type MyApp Extends wxApp

	Field frame:MyFrame

	Method OnInit:Int()
		frame = MyFrame(New MyFrame.Create(,,"Ctrl-A text", 100, 100))
		SetTopWindow(frame)
		frame.show()
		Return True
	End Method

End Type

Type MyFrame Extends wxFrame

	Field text:SelectAllTextCtrl

	Method OnInit()
	
		text = SelectAllTextCtrl(New SelectAllTextCtrl.Create(Self, -1,,,,,,wxTE_MULTILINE))
	
	End Method
	
End Type

Type SelectAllTextCtrl Extends wxTextCtrl

	Method OnInit()
	
		ConnectAny(wxEVT_KEY_DOWN, OnKeyDown)
	
	End Method

	Function OnKeyDown(evt:wxEvent)
		Local event:wxKeyEvent = wxKeyEvent(evt)

		If event.ControlDown() Then
			If event.GetKeyCode() = 65 Then ' 65 on Win32... 1 on Linux...
				SelectAllTextCtrl(event.parent).SetSelection(-1, -1)
			End If
		End If
		
		event.skip()
	End Function

End Type


Another simple way is to have the cursor at the very beginning of the control, and press shfit+end. For applications that you can't just edit the source to.

And home to bring the cursor to the beginning. Sometimes you'll need to right click & press copy, as ctrl+c won't work in some text controls either.

Sorry for bringing up an old thread, but theres still issues with this: I know of no way to get around the *ding* sound when doing ctrl+a, also the hack means the OnKeyDown is called everytime something is entered into a ctrl, which is very inefficient.

It doesn't ding here on Win2k, running wxCodeGen (see the middle tab pane with the text field which is set up for ctrl-A).

I don't think it's terribly inefficient? How fast can you type?

I suppose your right about the efficiency thing, its just something I expected to be standard.

It dings in xp sp2.