Jump to content


Photo

TextItem keep edit mode


  • Please log in to reply
23 replies to this topic

#1 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 20 January 2016 - 02:10 AM

Hello

I have a problem with a TextItem in an Inspector, maybe a bug ;).
I attach an quick exemple.

If you put a text in Inspector's TextItem, Label2's caption is changed, OK.
If you click on Label1, the clickevent's code trys to change TextItem's text to 'Test', but it doesn't work, the text shown doesn't change but Label2's caption is changes to 'Test'.

It's seems that is not possible to focus out the TextItem.

procedure TNxPropertyItem.SetValue is executed

If you change the NxTextItem1 option "AutoApply" to false this comportment disappaer. I think the TextItem keeps editmode up.

No urgence I'm using AutoApply at false for the moment.

 

I take this message to ask you if it's possible to give focus to TextItem. I didn't find a SetFocus or Focusing, Select or anything else nearby

For exemple if I click on a no focusable object (Label) I would like to target TextItem in order than typed text appear in the TextItem.

 

I hope i'm clear in my explaination :P

Thanks for your help
Qwaz

Attached Files



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 January 2016 - 11:05 AM

Hi,

 

You need to access to InplaceEditor since item is currently being edited:

 

NxTextItem1.Editor.Text := 'Test';

 

I hope that this helps


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 20 January 2016 - 12:09 PM

Hello

 

I understand but it implies that TextItem stay permanently in edit mode ? Even when I press return key to validate the TextItem'seditor text?

 

Thank you



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 January 2016 - 03:22 PM

When you press Return, or move to another item you can use .Value again.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#5 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 20 January 2016 - 08:36 PM

Hello

 

Thanks.

Ok for return, I'm confuse, I had a problem with it but I don't find the exact suite of operations to show it. I'll post it if I find exacts operations.

If I understand what you say, I need to use a code like this one in Label1 to be sure that the Value will changed

if Nxtextitem1.editor.?? then NxTextItem1.Editor.text := 'TestE' else NxTextItem1.value := 'TestV';

Could you help me to find the good property
I tested some properties and I inspected all properties of TextItem, Editor and Editor.EditInfo but I didn't find the good one, the best I found is .Focused but there is a problem if I exit by clicking in an other component (Edit1 for exemple). The focus stay on TextItem, so the code try to change "Value" so just Label2 is changed.

Don't you think it is not a problem, the focus should not be lost when user click on an other componment and editing mode closed by the way?

Thanks

 



#6 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 January 2016 - 08:50 PM

Hi,

 

Maybe you want to use something like this:

 

 if NextInspector1.EditingItem = nil then
     NxTextItem1.Value := 'Test'
  else
    NextInspector1.EditingItem.Editor.AsString := 'Test';

boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#7 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 20 January 2016 - 10:04 PM

Hi

 

Yes it's smell good :), I'll use it.

 

But (sorry :wacko: ) it doesn't solve the problem, when you have several Item in Inspector.

If one of them is inedit mode, you can't modifie another one, ok it's normal, but when you click in other coponment out of the inspector, the focus stay on Item and it's impossible to change any Item on Inspector.

 

It's not possible to test if edit mode is present on one of Item all the time befor try to modifie one else, how do you proced in this case please?

A way is to apply text on the inspector's OnExit event, like that

procedure TForm1.NextInspector1Exit(Sender: TObject);
begin
     if NextInspector1.EditingItem <> nil then  NextInspector1.ApplyTextBox(false);
end;

Don't you think it must be better to include that in KillFocus Wmessage override event?

 

 

I solve my second issue (give focus to an item)

procedure TForm1.Label2Click(Sender: TObject);
begin
     nextinspector1.EditItem(NxTextItem1,true);
     NxTextItem1.Editor.SelectAll;
end;

Regards



#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 January 2016 - 10:14 PM

Hi,

 

I will add such feature. I will need to add flag inside Options property to control this to not break old method.

 

It will be included in next update.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 20 January 2016 - 10:39 PM

You're a nice person thanks for your patience :)

 

Best regards
Qwaz



#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 20 January 2016 - 11:23 PM

Please try next:

 

Add poEndEditingOnExit flag in TInspectorPropertyOptions enum (at the top of NxInspector.pas file).

 

and then inside DoExit add next code:

 

procedure TNxCustomInspector.DoExit;
begin
  inherited;
  if poEndEditingOnExit in Options then
  begin
    ApplyTextBox;
    EndEditing;
  end;
  if not FEscapePressed then ApplyTextBox;
  RefreshItem(SelectedItem, ipCaption);
  RefreshItem(SelectedItem, ipMargin);
end;

boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#11 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 21 January 2016 - 12:55 AM

:)

 

Nice job it works fine.



#12 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 21 January 2016 - 12:03 PM

Good, it will wait you in next update too.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#13 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 23 January 2016 - 09:34 PM

Hi, I'm back :D

I meet a new problem, always with editing.

When I modify a TextItem's value DoItemEditorEdit is fired in NxInspector
 

  if not Assigned(FEditingItem) then Exit;
  with Sender as TNxCustomEdit do
  begin
    if itoAutoApply in FEditingItem.Options then
      FEditingItem.Value := AsString;
    DoEdit(FEditingItem, AsString, Accept);
  end;

In this procedur you test if FEditingItem is assigned at the begin, and

FEditingItem.Value := AsString;

call NxInspector's OnChange procedure.


If I change the TextItem's enabled statut in his OnChange (even enabled is set to true) when the code goes on with

DoEdit(FEditingItem, AsString, Accept);

FEditingItem is nil because when I've tried to change enabled statut, EndEditing has been call and FEditingItem has been set to nil by this call.


I hope I'm clear.

Please find an exemple in the post if is needed, I hope no, but I know my english is not the best ^^.

I know I can solve my problem myself in my code but maybe you want to prevent this issue with someone else. Probably just with a new assigned test before calling DoEdit.

 

Have a nice day

Qwaz



#14 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 24 January 2016 - 01:30 AM

Hi Qwaz,

 

Maybe we can do something with checking again with nil, but if you can send me demo it will help much more.

 

Thanks.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#15 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 24 January 2016 - 11:10 AM

Hi

 

Sorry I forgot to attach the demo...

 

Thanks

Attached Files



#16 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 25 January 2016 - 08:30 PM

Hi,

 

Try to update next procedure:

 

procedure TNxPropertyItem.SetEnabled(const Value: Boolean);
begin
  FEnabled := Value;
  if not FEnabled then Change(ckDisable);
end;

boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#17 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 28 January 2016 - 10:34 PM

Hi

 

It work in the demo but if you set TextItem's enable to false, an error is rized because "Item" is nil in NextInspector1Edit.

 

++

Qwaz



#18 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 16 February 2016 - 03:27 PM

Hi

 

The new code (post #16) raises a problem of appearance disabled/enabled of Item, the item stay at disabled appearance even enabled is set to true.
 
Thx

 

++

Qwaz



#19 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 17 February 2016 - 12:41 AM

Hi

 

Can you please download latest release. I think that I have already fixed this problem.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#20 Qwazerty

Qwazerty
  • Members
  • 73 posts
  • Gender:Male
  • Location:France

Posted 18 February 2016 - 12:04 PM

Hi

 

Humm,  I have re-installed the version 5 in january so I think I already use the last update.
The last Upload is from Oct 06, 2015.

 

Have a nice day

Qwaz






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users