Some Questions about the FileObject gadget

15 posts / 0 new
Last post
AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
Some Questions about the FileObject gadget

Hi,

I am writing a reaction prefs program and want to have a file gadget that shows a button and a string box next to it which contains the current path/file that has been selected.
I create this using the following:

LAYOUT_AddChild, OBJ(OBJ_DISKRSTRING)=GetFileObject,
GA_RelVerify, TRUE,
STRINGA_MinVisible, 36,
GA_ID,OBJ_DISKRSTRING,
End,

And this gives me exactly what I want. BUT....I cannot find any way to populate the "string" portion of the gadget. With a typical string gadget I would use something like this:

SetGadgetAttrs(GAD(OBJ_DISKRSTRING),
window, NULL, // window, requester
STRINGA_TextVal, filename,
TAG_DONE);

but this does not work with the GetFileObject type.

So,

1) How do I have this gadget how me a string with text for the path/file when it is created?

2) How do I have the text in the string part of this gadget update when I change the text for path/file?

3) How do I change the size of the string text box for this gadget.

I have spent a couple hours looking at the autodocs and have not discovered the answer yet.

Thank you!

thomas
thomas's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2011-05-16 14:23
STRINGA_ attributes are for

STRINGA_ attributes are for string gadgets. The GetFile gadget only listens to GETFILE_ attributes.

1) set GETFILE_FullFile or GETFILE_Drawer and GETFILE_File.

2) use SetAttrs and RefreshGList. SetGadgetAttrs does not seem to work.

3) the size should automatically be adjusted to the size of the surrounding layout group.

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
Aha...I thought that the

Aha...I thought that the GETFILE_FullFile and GETFILE_File were used only for the requester window that opens when you go to select a file. That works.

Thank you!

As for the size, if I increase the width of the window, ALL of the gadgets increase in size, so the filelister string box only increases a little bit. Is there a way to stop my slider gadgets and button gadgets from stretching when I increase the size of my window?
The checkbox already works that way. That sems to be it's default nature. What attribute do I need to set to keep my slider and buttons from being scalable. They are not image mapped, just simple gadgets.

Thanks!

salass00
salass00's picture
Offline
Last seen: 7 months 2 weeks ago
Joined: 2011-02-03 11:27
@AmigaOneFan As for the

@AmigaOneFan


As for the size, if I increase the width of the window, ALL of the gadgets increase in size, so the filelister string box only increases a little bit. Is there a way to stop my slider gadgets and button gadgets from stretching when I increase the size of my window?
The checkbox already works that way. That sems to be it's default nature. What attribute do I need to set to keep my slider and buttons from being scalable. They are not image mapped, just simple gadgets.

Set CHILD_WeightedWidth and/or CHILD_WeightedHeight to 0. F.e. if you want an object to be always only be displayed at it's minimum size in the layout then just add it like this:

  1. ...
  2. LAYOUT_AddChild, IIntuition->NewObject(...),
  3. CHILD_WeightedWidth, 0,
  4. CHILD_WeightedHeight, 0,
  5. ...
trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Some Questions about the FileObject gadget

@salass00

The weighted height/width are passed as child tags so they must be put AFTER the object's TAG_DONE (or "End", if you're using the ReAction macros). As some less experienced programmers tend to put the CHILD_ tags inside the object definition (which is wrong), the following is a more illustrative example:

  1. ...
  2. LAYOUT_AddChild, IIntuition->NewObject(...,
  3. // define your object here
  4. TAG_DONE),
  5. CHILD_WeightedWidth, 0,
  6. CHILD_WeightedHeight, 0,
  7. ...

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
@salass00 @trixie Awesome.

@salass00
@trixie

Awesome. That's exactly what I needed!

Thanks!

...Now...can anyone tell me how to trigger an event when a particular program name is started in intuition? For example, if someone starts a program named "DPaint", no matter what path is is started from, I want to trigger an event WHEN IT IS FIRST STARTED only.

Thanks!

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
Another question about the

Another question about the GetFileObject gadgets.

I notice that when I have GA_RelVerify TRUE then if I select the disk icon I get an event for that object.

BUT....I do not get an event when I click in the filename string gadget for the GetFileObject and edit the string manually without opening a filerequester.
Is there a way to have an event triggered when the string edit part of the GetFile object is changed?

Thanks!

thomas
thomas's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2011-05-16 14:23
Yes, as the autodocs say the

Yes, as the autodocs say the gadget issues the OM_UPDATE method of its ICA_TARGET. You can set ICA_TARGET to ICTARGET_IDCMPUPDATE so that the method call is turned into an IDCMP_IDCMPUPDATE message which is sent to your window. In order to catch this message you need to set up a WINDOW_IDCMPHook and set WINDOW_IDCMPHookBits to IDCMP_IDCMPUPDATE.

Esample: http://thomas-rapp.homepage.t-online.de/examples/getfile.c

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
@Thomas, Thank you for the

@Thomas,

Thank you for the getfile example. This makes a lot more sense now.

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
Okay...another question about

Okay...another question about the GETFILE parameters.

When I set the flag GETFILE_AllowEmptyFileSelection, TRUE, I do not see any change in behavior of my file requester. When I select an empty file by using cancel, shouldn't it return a success instead of a fail if this is set?

For example....

getfile = NewObject(GETFILE_GetClass(), NULL,
GETFILE_TitleText, sound_requester_strings[num],
GETFILE_ReadOnly, TRUE,
GETFILE_RejectIcons, TRUE,
GETFILE_DoPatterns, TRUE,
GETFILE_AllowEmptyFileSelection, TRUE, // SAC- test!!!
GETFILE_AcceptPattern,filetype,
GETFILE_Pattern, filetype,
TAG_DONE);

if (getfile) // success
{
// got the file here....or an empty name if empty file selected?
}

Shouldn;t this go into the success code with AllowEmptyFileSelection set?

thomas
thomas's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2011-05-16 14:23
NewObject creates the gadget,

NewObject creates the gadget, it does not open the requester. You have to call the GFILE_REQUEST method to open the requester.

GFILE_REQUEST returns FALSE if the user clicked Cancel and TRUE if the user clicked OK.

GETFILE_AllowEmptyFileSelection,FALSE will not allow the user to click OK if the file field is not filled.

trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: Some Questions about the FileObject gadget

@AmigaOneFan

can anyone tell me how to trigger an event when a particular program name is started in intuition? For example, if someone starts a program named "DPaint", no matter what path is is started from, I want to trigger an event WHEN IT IS FIRST STARTED only.

I'm not sure Intuition can do that. But you can register your app with the Application Library, set "REGAPP_AppNotifications, TRUE" at registration time, and your app will then receive an APPLIBMT_AppRegister notification whenever some other application starts and registers.

See the Application Library page in the AmigaOS4 Wiki to learn how to use the library and its notification system.

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

thomas
thomas's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2011-05-16 14:23
Please don't discuss

Please don't discuss off-topic. This has been answered in this thread: http://www.os4coding.net/forum/making-desktop-magic-program-os4

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
@thomas, Yes, of course!

@thomas,

Yes, of course! The call to create the object will return an error if the object cannot be created, it is the call to open the requester that returns the status determined by AllowEmptyFileSelection. What was I thinking!?!
Sorry for the dumb question. Thank you for your patience.

AmigaOneFan
AmigaOneFan's picture
Offline
Last seen: 11 years 3 weeks ago
Joined: 2011-11-14 16:18
@thomas wrote "Please don't

@thomas wrote "Please don't discuss off-topic."

Sorry...that was my fault. I asked the same question here and in another thread as well.

Log in or register to post comments