Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » LineEdit, EditFields, DocEdit » LineEdit how to set selection from code
LineEdit how to set selection from code [message #48956] Fri, 10 November 2017 08:49 Go to next message
slashupp is currently offline  slashupp
Messages: 147
Registered: July 2009
Experienced Member
(orig question was regarding fonts)
I think because of block-selection it MUST have regularly spaced characters?
"LineEdit can do any font as long as it is monospace" Wink
and that this is so by design

Now I want to select some text from code and I cannot figure out how to.
Say I have three lines of text in the LineEdit like so:
abc def ghi
jkl mno pqr
stu vwx yz
and I want to select from code the word "mno", how to do that?
I looked at SetSelection() but it does strange things - don't understand it at all.

Also: how do I set the blinking caret to be at the start of the above selection?


PS:
We really really really need proper documentation for Upp.
Is there such an effort underway? I'd like to contribute to it for the bits I understand
and usage/call examples similar to how http://en.cppreference.com/w/ does it.
I spend a lot of time tracing code for info that should be part of proper documentation.

[Updated on: Sat, 11 November 2017 10:29]

Report message to a moderator

Re: LineEdit how to set selection from code [message #48961 is a reply to message #48956] Sun, 12 November 2017 08:34 Go to previous message
slashupp is currently offline  slashupp
Messages: 147
Registered: July 2009
Experienced Member
never mind Smile used the following to figure it out
Leaving it here for the next guy...

#include <CtrlLib/CtrlLib.h>
using namespace Upp;

struct test_led : public TopWindow
{
	typedef test_led CLASSNAME;
	int l,h;
	Button btnLoad, btntest1, btntest2;
	EditInt eba, ebc;
	LineEdit led;
	test_led()
	{
		Title("test_led").Sizeable().CenterScreen();
		Add(btnLoad.LeftPos(5,60).TopPos(5,20)); btnLoad.SetLabel("Load..").WhenPush << [this]{ OpenFile(); };
		Add(btntest1.LeftPos(70,60).TopPos(5,20)); btntest1.SetLabel("testget").WhenPush << [this]{ testget(); };
		Add(btntest2.LeftPos(140,60).TopPos(5,20)); btntest2.SetLabel("testset").WhenPush << [this]{ testset(); };
		Add(eba.LeftPos(210,100).TopPos(5,20));
		Add(ebc.LeftPos(320,100).TopPos(5,20));
		Add(led.HSizePosZ().VSizePosZ(30));// TopPosZ(30)); <--loses scrollbars!?
	}
	
	virtual ~test_led() {}
	
	void OpenFile()
	{
		String sf=SelectFileOpen("Any\t*.*");
		if (!sf.IsEmpty()) { FileIn fis(sf); led.Load(fis); }
	}
	
	void testget()
	{
		led.GetSelection(l, h);
		eba=l;
		ebc=h;
	}
	
	void testset()
	{
		l=~eba;
		h=~ebc;
		led.SetSelection(l, h);
	}
};

GUI_APP_MAIN
{
	test_led().Run();
}

[Updated on: Sun, 12 November 2017 08:37]

Report message to a moderator

Previous Topic: How applying syntax, for example c++?
Next Topic: Adding simple Append to TextCtrl?
Goto Forum:
  


Current Time: Tue Feb 19 09:28:09 CET 2019

Total time taken to generate the page: 0.00687 seconds