Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
JAPI Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 16 Jahren, 9 Monaten
Letzter Beitrag:
vor 16 Jahren, 9 Monaten
Beteiligte Autoren:
Oyvind Sylta, Merten

Using cancel with j_fileselect

Startbeitrag von Oyvind Sylta am 09.10.2001 14:17

I can't find any documentation on how to catch the cancel event in j_fileselect. Is this possible, and if so, how to do it?

Antworten:

j_fileselect returns an emty string if the cancel button is pressed. It can be catched
by scanning the string length (=0). Have a look at the viewer example.

Have Fun

Merten

von Merten - am 10.10.2001 10:41
I find that it is not quite so easy.On my Windows2000 system both OK and Cancel seems to send the same string in return. It seems to depend on what you set for filename when you enter the j_fileselect. If the filename exists, this will come up as the default choise. Pressing Cancel will then give the filename as reply. If the filename does not exist, then j_filechoose will return an empty string if either OK or Cancel is pressed, as long as I DO NOT select a file first.

Comments? is this a system dependent behaviour?

Oyvind

von Oyvind Sylta - am 11.10.2001 09:01
Hi,

you are right. This is a BUG. I fixed it, but for the moment i'm not able to build new DLL's. Please be patient until next week.

If you are able to build the DLL by yourself change the following lines in fileselect.c:

line 314:
if((obj == jcancel)||(obj==jdialog))
{
filename[0]='\0';
break;
}

}
x=japi_getxpos(jdialog);
y=japi_getypos(jdialog);
japi_dispose(jdialog);
japi_enable(jframe);

chdir(mainpath);
#ifdef WIN32
sprintf(filename,"%s\\%s",localpath,localname);
#else
sprintf(filename,"%s/%s",localpath,localname);
#endif
return(filename);
}

into:

if((obj == jcancel)||(obj==jdialog))
{
localname[0]='\0';
localpath[0]='\0';
break;
}

}
x=japi_getxpos(jdialog);
y=japi_getypos(jdialog);
japi_dispose(jdialog);
japi_enable(jframe);

chdir(mainpath);
if((localpath[0]=='\0')&&(localname[0]=='\0'))
filename[0]='\0';
else
{
#ifdef WIN32
sprintf(filename,"%s\\%s",localpath,localname);
#else
sprintf(filename,"%s/%s",localpath,localname);
#endif
}
return(filename);
}

von Merten - am 11.10.2001 11:55
I'll wait for next week. While you are at it: When setting the file-name before calling j_fileselect, this pathway and the file-name will come up as defaults. However, if the filename does not exist, then the pathway will not be set, and it will default back to the application (?) pathway (directory).

This is not convenient for e.g. saving new files?

Oyvind

von Oyvind Sylta - am 12.10.2001 09:53
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.