Page 1 of 2

STRINGA_MarkActive

PostPosted: Wed Jun 14, 2017 11:51 am
by glames
Hello,

I'd like to select content from a String field when it is activated by user.
I tried to use STRINGA_MarkActive, TRUE but with no success.

From autodoc:
STRINGA_MarkActive (BOOL) (V50)
Mark contents of gadget when it goes active. This
includes the use of ActivateGadget() and friends and
when the user clicks into the gadget. Use this option
wisely. It should only be used on data that is sure
to change under user control. A single keypress in an
active gadget will replace the whole string data.
Be warned.

Any idea?

Thank you

Re: STRINGA_MarkActive

PostPosted: Wed Jun 14, 2017 10:00 pm
by broadblues
I'm not sure exactly what you want to do here.

You say "select content from" (my emphasis) do you mean you want to read the contents of the gadget when the user clicks into it?

If so set GA_Immediate,TRUE, and make sure IDCMP_GADGETDOWN is specified in the window IDCMP flags, the check the gadget in the WMHI_GADGETDOWN section of your event loop.

If you simply want the contents marked, then the tag you indicated should work..

Post the code that isn't working for you and I can give better advice.

Re: STRINGA_MarkActive

PostPosted: Thu Jun 15, 2017 12:45 pm
by glames
I'd simply want the content marked (ie; displayed in reverse-video, then when you press a (letter) key it deletes content and replace by this letter).

SDK:Examples/GUI/String/stringexample.c
I just added STRINGA_MarkActive, TRUE, To GID_STRING1

LAYOUT_AddChild, gadgets[GID_STRING1] = (struct Gadget*)StringObject,
GA_ID, GID_STRING1,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_MarkActive, TRUE,
STRINGA_MinVisible, 10,
STRINGA_MaxChars, SMAX,
StringEnd,


It doesn't work: I have to double-click to select the content (and make it visually selected).

I use AmigaOS 4.1 FE 1 Update 1 (no beta)

Thank you for your answer.

Re: STRINGA_MarkActive

PostPosted: Thu Jun 15, 2017 4:43 pm
by xenic
glames wrote:I'd simply want the content marked (ie; displayed in reverse-video, then when you press a (letter) key it deletes content and replace by this letter).

It must be possible because that's how the Workbench rename window works (the window that appears when you select the Workbench menu 'Icons/Rename'). Personally, I don't like it because that's not how most OS4.x string gadgets work and I almost always end up making the original name disappear by pressing a letter when my intent was to edit the name; not replace it.

Re: STRINGA_MarkActive

PostPosted: Thu Jun 15, 2017 7:18 pm
by broadblues
glames wrote:I'd simply want the content marked (ie; displayed in reverse-video, then when you press a (letter) key it deletes content and replace by this letter).


OK. So I was reading to much inot your wording then :-)



SDK:Examples/GUI/String/stringexample.c
I just added STRINGA_MarkActive, TRUE, To GID_STRING1

LAYOUT_AddChild, gadgets[GID_STRING1] = (struct Gadget*)StringObject,
GA_ID, GID_STRING1,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_MarkActive, TRUE,
STRINGA_MinVisible, 10,
STRINGA_MaxChars, SMAX,
StringEnd,



It doesn't work: I have to double-click to select the content (and make it visually selected).


Modify the example above to add a test string eg

with STRINGA_TextVal,"just a test",

you will see the gadget is marked on startup.

So it does work, but not it seams quite as you want it.

Another subtley, seem that the flag is cleared after a ActivateGadget() but not after a TAB_CYCLE

It's quite explictly reset by a single click into the gadget which is slightly at odds with the AutoDoc. Although that does make sense within the usage case mentioned by xenic above.

Re: STRINGA_MarkActive

PostPosted: Fri Jun 16, 2017 2:44 am
by broadblues
I updated the autodoc to more accurately reflect the current behaviour. (since 2009 or so)

* STRINGA_MarkActive (BOOL) (V50)
* Mark contents of gadget when it is made active. This
* includes the use of ActivateGadget() and friends,
* activating via keyboard short cut, and via tab cycling.
* When the user clicks into the gadget with the mouse
* the mark active status is cleared to prevent interference
* with editing the gadget contents. Normal double clicking
* to mark the contents still functions in this context.
* Use this option wisely. It should only be used on data
* that is sure to change under user control.
* A single keypress in an active gadget will replace the
* whole string data.
* Be warned.


So the gadget is never going to mark all with a single click even with this oprion on.

@glames

If you can say bit more about why you want the gadget to behave like this in your context, we might be able to suggest an alternative approach.

Re: STRINGA_MarkActive

PostPosted: Fri Jun 16, 2017 11:42 am
by glames
xenic wrote:
glames wrote:I'd simply want the content marked (ie; displayed in reverse-video, then when you press a (letter) key it deletes content and replace by this letter).

It must be possible because that's how the Workbench rename window works (the window that appears when you select the Workbench menu 'Icons/Rename'). Personally, I don't like it because that's not how most OS4.x string gadgets work and I almost always end up making the original name disappear by pressing a letter when my intent was to edit the name; not replace it.

Well, it's sometimes useful (for example, filter on messages in YAM), as your filter value changes every time.

Re: STRINGA_MarkActive

PostPosted: Fri Jun 16, 2017 11:48 am
by glames
broadblues wrote:Modify the example above to add a test string eg

with STRINGA_TextVal,"just a test",

you will see the gadget is marked on startup.

So it does work, but not it seams quite as you want it.

Yes, it works

Re: STRINGA_MarkActive

PostPosted: Fri Jun 16, 2017 11:57 am
by glames
broadblues wrote:I updated the autodoc to more accurately reflect the current behaviour. (since 2009 or so)

* STRINGA_MarkActive (BOOL) (V50)
* Mark contents of gadget when it is made active. This
* includes the use of ActivateGadget() and friends,
* activating via keyboard short cut, and via tab cycling.
* When the user clicks into the gadget with the mouse
* the mark active status is cleared to prevent interference
* with editing the gadget contents. Normal double clicking
* to mark the contents still functions in this context.
* Use this option wisely. It should only be used on data
* that is sure to change under user control.
* A single keypress in an active gadget will replace the
* whole string data.
* Be warned.


So the gadget is never going to mark all with a single click even with this oprion on.

Thank you, it's clearer now

broadblues wrote:@glames

If you can say bit more about why you want the gadget to behave like this in your context, we might be able to suggest an alternative approach.

Well, I have a filter feature in Dir Me Up that allows to display files upon their names. The filter value often changes entirely from one filter to another. That's why I'd like it. (You can see the same behaviour in YAM filtering)

Re: STRINGA_MarkActive

PostPosted: Fri Jun 16, 2017 1:18 pm
by broadblues
Well, I have a filter feature in Dir Me Up that allows to display files upon their names. The filter value often changes entirely from one filter to another. That's why I'd like it. (You can see the same behaviour in YAM filtering)


Ah okay, I personally always end up having to click twice in that YAM gadget when fine tuning filers, as I'm likely correcting a typo and so don;t want the whole string markded :-)

I would recomend sticking to the single activate, double click selected word, tripple click select all operation as tis is the standard behaviiour of string gadgets and you would need to do no work at all.

But if you really wanted to force that behaviour, then you would need to listen to the GADGETDOWN event and mark the gadget yourself with STRINGA_Mark. try a value of 0xFFFF0000 to mark the whole string without checking it's length.