STRINGA_MarkActive

This forum is for general developer support questions.

STRINGA_MarkActive

Postby glames » Wed Jun 14, 2017 11:51 am

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
glames
 
Posts: 14
Joined: Wed Aug 31, 2011 1:08 am

Re: STRINGA_MarkActive

Postby broadblues » Wed Jun 14, 2017 10:00 pm

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.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 480
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: STRINGA_MarkActive

Postby glames » Thu Jun 15, 2017 12:45 pm

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.
glames
 
Posts: 14
Joined: Wed Aug 31, 2011 1:08 am

Re: STRINGA_MarkActive

Postby xenic » Thu Jun 15, 2017 4:43 pm

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.
AmigaOne X1000 with 2GB memory - OS4.1 FE
xenic
 
Posts: 1053
Joined: Sun Jun 19, 2011 1:06 am

Re: STRINGA_MarkActive

Postby broadblues » Thu Jun 15, 2017 7:18 pm

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.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 480
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: STRINGA_MarkActive

Postby broadblues » Fri Jun 16, 2017 2:44 am

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.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 480
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: STRINGA_MarkActive

Postby glames » Fri Jun 16, 2017 11:42 am

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.
glames
 
Posts: 14
Joined: Wed Aug 31, 2011 1:08 am

Re: STRINGA_MarkActive

Postby glames » Fri Jun 16, 2017 11:48 am

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
glames
 
Posts: 14
Joined: Wed Aug 31, 2011 1:08 am

Re: STRINGA_MarkActive

Postby glames » Fri Jun 16, 2017 11:57 am

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)
glames
 
Posts: 14
Joined: Wed Aug 31, 2011 1:08 am

Re: STRINGA_MarkActive

Postby broadblues » Fri Jun 16, 2017 1:18 pm

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.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 480
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Next

Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 2 guests