TreeView, label editing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

TreeView, label editing

Hasko Heinecke
Imagine an application that displays some stuff in a tree view like this:

- Toys
-- Shovel (red)
-- Car (blue)
- Clothes
-- Shirt (yellow)

The important point is, the items can have some additional information
beside their "name", like the colors above. Now when I click on an item's
label, I want to edit its name but _not_ its color. Ideally, the color
string would be removed from the label before editing, and added again
afterwards.

So far, I have not found a possibility to implemented the desired behavior.
If anybody has an idea how to accomplish it, I'd be grateful. It might
involve calling Win32 APIs and that is not an area I know well.

Hasko Heinecke


Reply | Threaded
Open this post in threaded view
|

Re: TreeView, label editing

Hasko Heinecke
Here's an update to my problem:

> Imagine an application that displays some stuff in a tree view like this:
>
> - Toys
> -- Shovel (red)
> -- Car (blue)
> - Clothes
> -- Shirt (yellow)
>
> The important point is, the items can have some additional information
> beside their "name", like the colors above. Now when I click on an item's
> label, I want to edit its name but _not_ its color. Ideally, the color
> string would be removed from the label before editing, and added again
> afterwards.

After fiddeling around with TreeView>onAboutToEditLabel: I found that it is
possible to change the label during editig, BUT the edit widget has its
contents already set to the old label when #onAbout... is sent. So the
change is actually only displayed _after_ the edit, not quite what I
wanted...

Hasko


Reply | Threaded
Open this post in threaded view
|

Re: TreeView, label editing

Ian Bartholomew
Hasko,

> After fiddeling around with TreeView>onAboutToEditLabel: I found that it
> is possible to change the label during editig, BUT the edit widget has its
> contents already set to the old label when #onAbout... is sent. So the
> change is actually only displayed _after_ the edit, not quite what I
> wanted...

I came to the same conclusion. I could adjust the text when the edit was
finished, making sure the original colour description was retained, but it
was a bit fragile and not very pretty.

I did notice that the API for TVN_BEGINLABELEDIT mentions a
TVM_GETEDITCONTROL message which can be sent once the in-place editing has
started and answers the handle of the edit control window which Windows has
provided for the editing. It talks about using this for input verification
and limiting the size of the edited text. It _may_ then also be possible to
change the text being edited using normal EM_* messages (select all then
replace maybe) but I didn't go too deeply into it. I imagine you would also
have to subclass the TreeView class in Dolphin to make it usable.

One final thought. If your example was an accurate indication of what you
wanted to do, indicate the colour of each object, how about using
appropriately coloured  solid icons. You could then allow the text to be
edited but the colour icon would not change. I can't remember if there are
any limits on the icon size but it may also be possible to have a icon
containing text and giving the colour name.

Regards
    Ian


Reply | Threaded
Open this post in threaded view
|

Re: TreeView, label editing

Hasko Heinecke
"Ian Bartholomew" <[hidden email]> wrote:
> Hasko,
>
> > After fiddeling around with TreeView>onAboutToEditLabel: I found that it
> > is possible to change the label during editig, BUT the edit widget has
its
> > contents already set to the old label when #onAbout... is sent. So the
> > change is actually only displayed _after_ the edit, not quite what I
> > wanted...
[...]
> I did notice that the API for TVN_BEGINLABELEDIT mentions a
> TVM_GETEDITCONTROL message which can be sent once the in-place editing has
> started and answers the handle of the edit control window which Windows
has
> provided for the editing. It talks about using this for input verification
> and limiting the size of the edited text. It _may_ then also be possible
to
> change the text being edited using normal EM_* messages (select all then
> replace maybe) but I didn't go too deeply into it. I imagine you would
also
> have to subclass the TreeView class in Dolphin to make it usable.
[...]

I must admit I really don't know anything about the Win32 APIs. However, the
example I found suggested that I should be able to get the edit control in
the way you described. I implemented

ExtendedTreeView>nmBeginLabelEdit:
  (self sendMessage: 4120) = 0 ifTrue: [self halt]. "4120 is
TVM_GETEDITCONTROL"
  ^super nmBeginLabelEdit: bla

However, the message always returns 0, indicating there is no edit control.
Does anybody know how to get around this. The C++ examples I found on
various web sites describing this stuff were pretty straight-forward. They
used a macro called GetEditControl. Does this do anything else apart from
sending the message? What am I missing?

By the way, if there is a solution, I'll put my ExtendedTreeView on the
Dolphin Wiki...

Hasko


Reply | Threaded
Open this post in threaded view
|

Re: TreeView, label editing

Ian Bartholomew
Hasko,

> "4120 is TVM_GETEDITCONTROL"

My (admittedly out of date but hopefully still correct) documentation
indicates that the numeric value is 4367, and using this value does appear
to return a handle - which is a good sign <g>.

Can someone with an up to date commctrl.h confirm which, if either, is right
please?

Ian


Reply | Threaded
Open this post in threaded view
|

Re: TreeView, label editing

Chris Uppal-3
Ian,
>
> > "4120 is TVM_GETEDITCONTROL"
>
> My (admittedly out of date but hopefully still correct) documentation
> indicates that the numeric value is 4367, and using this value does
appear
> to return a handle - which is a good sign <g>.
>
> Can someone with an up to date commctrl.h confirm which, if either, is
right
> please?

In my VC++6 installation TVM_GETEDITCONTROL is TV_FIRST + 15.  I.e.
4367.

> Ian

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: TreeView, label editing

Ian Bartholomew
In reply to this post by Hasko Heinecke
Hasko,

> However, the message always returns 0, indicating there is no edit
control.
> Does anybody know how to get around this. The C++ examples I found on
> various web sites describing this stuff were pretty straight-forward. They
> used a macro called GetEditControl. Does this do anything else apart from
> sending the message? What am I missing?

The attached "experiment" seems to work, allowing for some validation and
formatting considerations, in the way you want. In the end it only needed a
single method adding to TreeView, rather than a subclass, which made it a
bit easier.

I've attached a V4 package but if you are using V2 or V3 you should be able
to see what is happening - V4 packages are text only.

Regards
    Ian



























begin 666 test.zip
M4$L#!!0````(`-AQDRH]"6;*X @``( A```(````=&5S="YP86/-6&MOVT86
M_>P`^0]CIX#D;57P_5"P"]B2G*;("[&;?@A:@")'%EN:HY)4'.^F_WWOG1?)
M$64K3;!;T)+(F3MWSCUS[IVA/Y%-DOZ>7%/RZ?$C=3O])WDC;\ODAD[)J*%U
M,_J^M=@D']_1JLY9.276T\>/CI9)G:<S=G-#RP;LK\">U&MV^_@1#FL'<COI
M7'L8"9N3LRPCS9IJ2'5:Y9NF/NEUID52UQQ7_1TI&*LIN:'-FF6J[;I@RZ10
M3Q6MV;9*123H2CGG?EYA(\!/LFQ*GKR\NZHH?<4R^M1H>P-N(#):M1T8(C[=
M@?N:%JM>F )1WSOZ>9?36S+Y%WE2T4V1I/1%LJ3%SWFSGNYU)<)1K@9-5(R#
M1B?G>9E4=^29H.650<.2]SYK)YF2\25M2$EO.YY.P=7)6T6EZ2,IBK=="#T7
M+5L8^&A.5\FV:,@'8&+TU)BBJX&*5O2/;5[GS>[:U;1YT^G'"9]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K&@PWNDZ'<%*LG.[KG%$0+M;<=JYY3H!ZKQEZM*11G&<OFL
M5B^6J$&'06E+C<* U8TOT0'T6'PFC>^>9=&ZBA5B6^B]<ZX*B"\ST+%TCU(E
M=NUL$P'<X4I&EHS5)Z:*`Q67)MEQ,,0^3%^&[\?2M]XOM%JB$+4$11YV%: =
M'B,N88 .5 <Q\H7?$4I!>3[\'.GIO<NL_1JWK-5_]>-JA^K&T4UNK+9'S^ F
M;LD2S S0%[L[=WH*A;Z5@A:</H':O;1ZZ#K4<I^=:X:X/^:!4ZBW$WVXWWJ
M*]N\&; !=7C2HUJ7]JPT`&!_VNG=WHH[V13JC=OKYY5)63MK1/JR]-4Z[M>M
MNKY4M^ITHGXC=:QW7!7V(2NHZYO74MJ'K+4:XF38IYSV-Q'SLMNU^<IGC+_3
MBU\D,3B*M-TSC'IK5[C45B-B#BWQ*"F0NW\<:UM;;F!?X\"CT!YPWM&VMEKN
MAU]I/?&H1('K[MJ]Y8F-7<PC^FP7/?#O#7FJY9%ZA[Y(ZB"T&/%,L&\Q+>')
MB_#/=T0\EHY6>97_;OLO4$L!`A0`% ````@`V'&3*CT)9LK@" ``@"$```@`
M`````````0`@`+:!`````'1E<W0N<&%C4$L%!@`````!``$`-@````8)````
!````
`
end


Reply | Threaded
Open this post in threaded view
|

Re: TreeView, label editing

Ian Bartholomew
In reply to this post by Chris Uppal-3
Thanks Chris.

4367 was indeed right and does work as expected.

Ian