Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology
Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered
You are not logged in.
Before creating the nonuichat plugit, I realized I should have a simple way to debug without getting into the browser side scripting, and perhaps could evade some of the 3d buffer issues involved when putting containers and windows on top of the os3d buffer. So I am going to create a Text Entry and Display Plugit, which will have a "sendtext" event that will send text from a text entry field to other plugits when the user presses enter on a _CBcompTextValidation object and a "received text" action when other plugits send strings to it. It will also have "show" and "hide" actions to display and hide the interface. Maybe it will look good enough not to get into html scripting....I'll see if it behaves itself with bitmap widgets.
Last edited by hebdemnobad (24-Sep-2014 20:41:20)
Offline
Off to work outside...here is the struct declaration:
struct Chatwindow = [
CHATwindow_plugin_instance : PInstance,
CHATwindow_window_object_container : ObjContainer,
CHATwindow_fatherwindow : ObjWin,
CHATwindow_parent_chat_window : ObjWin,
CHATwindow_chat_font : ObjFont,
CHATwindow_ongoing_chat_textfield : CompText,
CHATwindow_chat_entry_textfield : CompText,
]mkChatwindow;;
Offline
Hi,
To debug, you can display the texte in the Scol console.
I agree, but having this struct will allow a user to send and receive messages.
Offline
Chat plugIt without UI, it send all the command by "Send AX command" event and get The Ax command by "Get AX command" action
You have to get this command in the javascrip code of your page to decompose them and use them correctly
(not tested)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PLUGIN name="Chat command" version="1.0" type="network">
<DESCRIPTION>Chat command</DESCRIPTION>
<HELP>http://www.openspace3d.com/documentation/fr/plugits/network/chatplugit.html</HELP>
<RESOURCE>
</RESOURCE>
<EDITOR>
<SCRIPT path="./echatcmd.pkg" />
</EDITOR>
<CLIENT minstance="true">
<SCRIPT path="./cchatcmd.pkg" />
<ACTION name="Get message" />
<ACTION name="Get private message" />
<ACTION name="Get AX command" />
<EVENT name="Message" />
<EVENT name="PrivateMessage" />
<EVENT name="Command" />
<EVENT name="Send AX command" />
</CLIENT>
</PLUGIN>
/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com
Copyright (c) 2012 I-maginer
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt
-----------------------------------------------------------------------------
*/
struct PlugChat = [
CHAT_instance : PInstance,
CHAT_netcomm : NetComm,
CHAT_bState : I
]mkPlugChat;;
fun getCommandFromString(s)=
let strextr s -> lp in
utf8tostr hd hd lp;;
fun getArgumentsFromString(s)=
let getCommandFromString s -> command in
let substr s 0 strlen command -> s in //remove command
let strextr s -> l in
let "" -> lastarg in
let nil -> largs in
(
let sizelist l -> size in
let 0 -> i in
let 0 -> state in
let 1 -> laststate in
while (i < size) do
(
let nth_list l i -> lwords in
let sizelist lwords -> wsize in
let 0 -> w in
while (w < wsize) do
(
set laststate = state;
let nth_list lwords w -> word in
(
if (!strcmp "'" substr word 0 1) || (!strcmp "'" substr word ((strlen word) - 1) 1) then
(
set state = !state;
)
else nil;
if (laststate != state) then
(
set largs = lcat largs lastarg::nil;
set lastarg = word;
)
else
set lastarg = strcatn lastarg::" "::word::nil;
);
set w = w + 1;
);
set i = i + 1;
);
set largs = lcat largs lastarg::nil;
);;
fun cbDestroy(inst, from, action, param, reply, constr)=
0;;
fun addChatText(constr, text)=
let strcatn "addMessage"::" "::"'"::(strreplace text "\n" "<br>")::"'"::nil -> text in
SendPluginEvent constr.CHAT_instance "Send AX command" (strtoutf8 text) nil;
0;;
fun addChatPrivateText(constr, uid, text)=
let strcatn "addPrivateMessage"::" "::(itoa uid)::" "::"'"::(strreplace text "\n" "<br>")::"'"::nil -> text in
SendPluginEvent constr.CHAT_instance "Send AX command" (strtoutf8 text) nil;
0;;
fun cbLoginChanged(inst, netstr, userstr, newlogin, constr)=
let netUserGetLogin userstr -> login in
if (!strcmp login newlogin) then nil else
(
addChatText constr strcatn login::" >> "::newlogin::nil;
let strcatn "changeLogin"::" "::(itoa netUserGetId userstr)::" "::"'"::(strreplace addSlashes newlogin "\n" "<br>")::"'"::nil -> newlogin in
SendPluginEvent constr.CHAT_instance "Send AX command" (strtoutf8 newlogin) nil;
);
0;;
fun cbAddUser(inst, netstr, userstr, constr)=
if userstr == (netThisUser netstr) then nil else
let netUserGetLogin userstr -> login in
(
addChatText constr strcatn ">> "::login::" connected."::nil;
let strcatn "addUser"::" "::(itoa netUserGetId userstr)::" "::"'"::(strreplace addSlashes login "\n" "<br>")::"'"::nil -> login in
SendPluginEvent constr.CHAT_instance "Send AX command" (strtoutf8 login) nil;
);
0;;
fun cbDelUser(inst, netstr, userstr, constr)=
let netUserGetLogin userstr -> login in
(
addChatText constr strcatn ">> "::login::" disconnected."::nil;
SendPluginEvent constr.CHAT_instance "Send AX command" (strtoutf8 (strcatn "delUser"::" "::(itoa netUserGetId userstr)::nil)) nil;
);
0;;
fun cbRoomChanged(inst, netstr, room, constr)=
addChatText constr strcatn "<strong>Welcome "::(netThisLogin netstr)::" to "::room::".</strong>"::nil;
0;;
fun cbDisconnected(inst, netstr, constr)=
if(!constr.CHAT_bState) then nil else
addChatText constr "<strong><<< Disconnected.</strong>";
set constr.CHAT_bState = 0;
0;;
fun cbSConnected(inst, netstr, constr)=
set constr.CHAT_bState = 1;
addChatText constr "<strong>>>> Connected.</strong>";
0;;
fun cbGetMessage(inst, from, action, param, reply, constr)=
if (param == nil) || (!strcmp (strtrim param) "") then nil else
addChatText constr param;
0;;
fun cbGetPrivateMessage(inst, from, action, param, reply, constr)=
let strfind " " param 0 -> pos in
let atoi substr param 0 pos -> uid in
let substr param pos + 1 ((strlen param) - pos) -> message in
(
addChatPrivateText constr uid message;
);
0;;
fun cbGetAxCommand(inst, from, action, param, reply, constr)=
//get the first word for command
let getCommandFromString param -> command in
let getArgumentsFromString param -> args in
(
if (!strcmp command "message") && (strcmp (hd args) "") && (args != nil) then
(
let utf8tostr (hd args) -> val in
if (!strcmp "/" (substr val 0 1)) then
(
SendPluginEvent inst "Command" (substr val 1 ((strlen val) - 1)) nil;
SendPluginEvent inst "Message" strcat "<strong>%login% << </strong>" (substr val 1 ((strlen val) - 1)) nil;
)
else
(
SendPluginEvent inst "Message" strcat "<strong>%login% > </strong>" val nil;
);
)
else if (!strcmp command "privateMessage") && (strcmp (hd tl args) "") && (args != nil) then
(
let hd args -> uid in
let utf8tostr (hd tl args) -> val in
let netGetUserById constr.CHAT_netcomm (atoi uid) -> duser in
if (!strcmp "/" (substr val 0 1)) then
(
SendPluginEvent inst "Command" (substr val 1 ((strlen val) - 1)) nil;
if (duser == nil) then nil else
(
addChatPrivateText constr (atoi uid) strcatn "<strong>"::(netThisLogin constr.CHAT_netcomm)::" << </strong>"::(substr val 1 ((strlen val) - 1))::nil;
SendPluginEvent inst "PrivateMessage" strcatn uid::" <strong>%login% << </strong>"::(substr val 1 ((strlen val) - 1))::nil nil;
0;
);
)
else
(
if (duser != nil) then
(
addChatPrivateText constr (atoi uid) strcatn "<strong>"::(netThisLogin constr.CHAT_netcomm)::" > </strong>"::val::nil;
SendPluginEvent inst "PrivateMessage" strcatn uid::" <strong>%login% > </strong>"::val::nil nil;
0;
)
else
(
addChatPrivateText constr (atoi uid) strcatn "<<< <strong>This user left the chat</strong>"::nil;
0;
);
);
)
else nil;
SendPluginEvent inst command utf8tostr (listToString args) nil;
);
0;;
fun cbSendMessageStr(navigator, constr, message, args)=
"";;
fun deleteOb(inst, constr)=
cbDestroy inst nil nil nil nil constr;
0;;
fun newOb(inst)=
let mkPlugChat [inst netcomOS3D 0] -> constr in
(
PluginRegisterAction inst "Get message" mkfun6 @cbGetMessage constr;
PluginRegisterAction inst "Get private message" mkfun6 @cbGetPrivateMessage constr;
PluginRegisterAction inst "Get AX command" mkfun6 @cbGetAxCommand constr;
setPluginInstanceCbDel inst mkfun2 @deleteOb constr;
);
0;;
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Offline
Thx!!!;
A question about local variables....how does the VM know that the constr argument in all the function definitions as an instance of the plugchat struct, since plugchat is assigned to a local variable?
Last edited by hebdemnobad (2-Sep-2014 13:23:07)
Offline
Right Arkeon, but I'm wondering how does the function localuser_enter_text take four arguments?
Offline
A question about local variables....how does the VM know that the constr argument in all the function definitions as an instance of the plugchat struct, since plugchat is assigned to a local variable?
A locale variable is known by the compiler while :
- the statement following its creation is NOT end;
- AND all references (typically all functions called from this statement) are NOT ended.
You could build a complex application with only the locale variables.
The following code is correct.
Read my comments to have an explanation. The locale variable can become an argument of another function.
At the end, "Bob and Alice are just married !" is written in the console.
// headers
proto myFunctionA = fun [ ] S;;
proto myFunctionB = fun [S] S;;
proto myPrintFunction = fun [S] I;;
fun myMainFunction ()=
_showconsole;
// first, myFunctionA is running.
// It returns a string value.
// Then, myPrintFunction is called as with argument this return value.
// once myPrintFunction returns, the return of myFunctionA is destroyed.
myPrintFunction myFunctionA;
0;;
fun myFunctionA ()=
// i create in memory and i set a locale variable to "Bob"
// a locale variable is only known in the next intruction AND all reference end.
// once this intruction ends, the locale variable is destroyed.
let "Bob" -> strVar in
// all the content into a bracket is an instruction.
// this intruction has several instructions itself.
// thus, the locale variable will be known until the end of the bracket.
(
// i set my locale variable
set strVar = strcat strVar " and Alice";
// i call another function with the locale variable (exactly, its memory reference) as argument.
// during the runtime of the function, the variable keep known.
// now the locale variable contains the result of myFunctionB.
set strVar = myFunctionB strVar;
// myFunctionA returns the locale variable.
// so, it is NOT destroyed even if the barcket ends.
// it exists until the end of the instruction which called it.
strVar
);;
fun myFunctionB (str)=
// the argument of the function "is" (in memory) our locale variable
// like it is an argument, it is known in all the function body.
_fooS "foo";
_fooS "bar";
// thus, we can use it here and return the concatenation result.
strcat str " are just married !";;
fun myPrintFunction (str)=
// our locale variable is still known.
_fooS " *-*-*-*-*-*";
_fooS str;
_fooS "Done !";
0;;
A basic example :
i want to divide 10 by another integer.
This code is wrong.
In 1, we create and set a locale variable
In 2, we change its value. It's ok because the locale variable is known by the Scol compiler
In 3, it's wrong, the locale variable is still used but it is unknown by the compiler. The compiler screams !
fun aFunction (arg)=
let 10 -> integer in // 1
set integer = integer / arg; // 2
_fooI integer; // 3
0;;
Here is the correct. I just add the brackets :
fun aFunction (arg)=
let 10 -> integer in
(
set integer = integer / arg;
_fooI integer;
0
);;
Offline
thank you for your reply Iri....I think I know now how to manipulate the custom object just using local variables, since the cbcreate function passes the temporary variable (of a struct) to various callbacks. the code below works in os3d, so that means I named the plugit files correctly. The next step is to get the action (display text input from other plugits) and event (triggered when user enters text into the interface, which passes the entered text to other plugits.)
so this will be useful not just for chat, but for any other text input/output using the scol vm without having to deal with browser issues. eventually i could make the editor configure the parameters of the various objects in the custom struct:
//struct definition
struct Chatwindow = [
CHATwindow_plugin_instance : PInstance,
CHATwindow_window_object_container : ObjContainer,
CHATwindow_parent_chat_window : ObjWin,
CHATwindow_chat_font : ObjFont,
CHATwindow_ongoing_chat_textfield : CompText,
CHATwindow_chat_entry_textfield : CompText
]mkChatwindow;;
fun cbDestroy(inst, from, action, param, reply, constr)=
_DSwindow constr.CHATwindow_parent_chat_window;
_DScontainer constr.CHATwindow_window_object_container;
_DScompText constr.CHATwindow_ongoing_chat_textfield;
_DScompText constr.CHATwindow_chat_entry_textfield;
_DSfont constr.CHATwindow_chat_font;
_CRwindow _channel nil 0 450 800 150 WN_NOBORDER|WN_CHILDINSIDE "A window";
0;;
//add text to ongoing_chat_textfield here
fun addtext(textobject, user_parameter,type,value)=
//update contents of chat interface
let ""-> empty_text_value in
(
_ADDcompText user_parameter.CHATwindow_ongoing_chat_textfield strcatn value:: "":: "\n"::nil user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
_SETcompText textobject "" user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_BEGIN;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
0;
);
0;;
///create plugit function
fun newOb(inst)=
let _CRwindow _channel nil 0 450 800 150 WN_NOBORDER|WN_CHILDINSIDE "A window" -> thisparentchatwindow in
let _CRcontainerFromObjWin _channel thisparentchatwindow 0 0 800 150 CO_CHILDINSIDE 0x000000 "hackerwindow" -> thiscontainer in
//let......code here to make fatherwindow here -> thisfatherwindow in
let _CRfont _channel 12 0 0 "Lucida Console"-> thisfont in
let _CRcompText _channel thiscontainer nil [0 101] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_WORDWRAP|CT_EDITLINE 0 800 50 "text entry field" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil -> thistextentryfield in
let _CRcompText _channel thiscontainer nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_LABEL|CT_WORDWRAP|CT_LABEL|CT_SELECT OBJ_CONTAINER_KEYDOWN 800 100 strcat "text entry here" "\n" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil-> thisongoingchatfield in
let mkChatwindow [inst thiscontainer thisparentchatwindow thisfont thisongoingchatfield thistextentryfield]->constr in
(
_CBcompTextValidation constr.CHATwindow_chat_entry_textfield @addtext constr CT_VALIDENTER;
_PAINTcontainer constr.CHATwindow_window_object_container;
PluginRegisterAction inst "Destroy" mkfun6 @cbDestroy constr;
);
0;;
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Offline
Hello,
your code seems correct.
In cbDestroy function, why i read :
_CRwindow _channel nil 0 450 800 150 WN_NOBORDER|WN_CHILDINSIDE "A window";
an error produced by copy / paste?
And think to indent your code ! At least, i should see directly the function block
fun functionA ( ...)=
// code
fun functionB ( ...)=
// code
fun functionC ( ...)=
// code
Offline
When I paste into post from bluefish, the indents change.
I added the code in the cbdestroy function to test it....using the os3d editor, the window containing the interface doesn't get destroyed so I put that code in to see if the function was even working.
Offline
you must provide a destroy callback for the instance in newOb function
//struct definition
struct Chatwindow = [
CHATwindow_plugin_instance : PInstance,
CHATwindow_window_object_container : ObjContainer,
CHATwindow_parent_chat_window : ObjWin,
CHATwindow_chat_font : ObjFont,
CHATwindow_ongoing_chat_textfield : CompText,
CHATwindow_chat_entry_textfield : CompText
]mkChatwindow;;
fun deleteOb(inst, constr)=
_DSwindow constr.CHATwindow_parent_chat_window;
_DScontainer constr.CHATwindow_window_object_container;
_DScompText constr.CHATwindow_ongoing_chat_textfield;
_DScompText constr.CHATwindow_chat_entry_textfield;
_DSfont constr.CHATwindow_chat_font;
0;;
//add text to ongoing_chat_textfield here
fun addtext(textobject, user_parameter,type,value)=
//update contents of chat interface
let ""-> empty_text_value in
(
_ADDcompText user_parameter.CHATwindow_ongoing_chat_textfield strcatn value:: "":: "\n"::nil user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
_SETcompText textobject "" user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_BEGIN;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
0;
);
0;;
///create plugit function
fun newOb(inst)=
let _CRwindow _channel nil 0 450 800 150 WN_NOBORDER|WN_CHILDINSIDE "A window" -> thisparentchatwindow in
let _CRcontainerFromObjWin _channel thisparentchatwindow 0 0 800 150 CO_CHILDINSIDE 0x000000 "hackerwindow" -> thiscontainer in
//let......code here to make fatherwindow here -> thisfatherwindow in
let _CRfont _channel 12 0 0 "Lucida Console"-> thisfont in
let _CRcompText _channel thiscontainer nil [0 101] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_WORDWRAP|CT_EDITLINE 0 800 50 "text entry field" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil -> thistextentryfield in
let _CRcompText _channel thiscontainer nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_LABEL|CT_WORDWRAP|CT_LABEL|CT_SELECT OBJ_CONTAINER_KEYDOWN 800 100 strcat "text entry here" "\n" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil-> thisongoingchatfield in
let mkChatwindow [inst thiscontainer thisparentchatwindow thisfont thisongoingchatfield thistextentryfield]->constr in
(
_CBcompTextValidation constr.CHATwindow_chat_entry_textfield @addtext constr CT_VALIDENTER;
_PAINTcontainer constr.CHATwindow_window_object_container;
setPluginInstanceCbDel inst mkfun2 @deleteOb constr;
);
0;;
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Offline
thx guys I fixed the destroy function problem.
//struct definition
struct Chatwindow = [
CHATwindow_plugin_instance : PInstance,
CHATwindow_window_object_container : ObjContainer,
CHATwindow_parent_chat_window : ObjWin,
CHATwindow_chat_font : ObjFont,
CHATwindow_ongoing_chat_textfield : CompText,
CHATwindow_chat_entry_textfield : CompText
]mkChatwindow;;
fun cbDestroy(inst, from, action, param, reply, constr)=
_DScompText constr.CHATwindow_ongoing_chat_textfield;
_DScompText constr.CHATwindow_chat_entry_textfield;
_DSfont constr.CHATwindow_chat_font;
_DScontainer constr.CHATwindow_window_object_container;
_DSwindow constr.CHATwindow_parent_chat_window;
0;;
fun deleteOb(inst, constr)=
cbDestroy inst nil nil nil nil constr;
0;;
//add text to ongoing_chat_textfield here
fun addtext(textobject, user_parameter,type,value)=
//update contents of chat interface
let ""-> empty_text_value in
(
_ADDcompText user_parameter.CHATwindow_ongoing_chat_textfield strcatn value:: "":: "\n"::nil user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
_SETcompText textobject "" user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_BEGIN;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
0;
);
0;;
///create plugit function
fun newOb(inst)=
let _CRwindow _channel nil 0 450 800 150 WN_NOBORDER|WN_CHILDINSIDE "A window" -> thisparentchatwindow in
let _CRcontainerFromObjWin _channel thisparentchatwindow 0 0 800 150 CO_CHILDINSIDE 0x000000 "hackerwindow" -> thiscontainer in
//let......code here to make fatherwindow here -> thisfatherwindow in
let _CRfont _channel 12 0 0 "Lucida Console"-> thisfont in
let _CRcompText _channel thiscontainer nil [0 101] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_WORDWRAP|CT_EDITLINE 0 800 50 "text entry field" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil -> thistextentryfield in
let _CRcompText _channel thiscontainer nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_LABEL|CT_WORDWRAP|CT_LABEL|CT_SELECT OBJ_CONTAINER_KEYDOWN 800 100 strcat "text entry here" "\n" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil-> thisongoingchatfield in
let mkChatwindow [inst thiscontainer thisparentchatwindow thisfont thisongoingchatfield thistextentryfield]->constr in
(
_CBcompTextValidation constr.CHATwindow_chat_entry_textfield @addtext constr CT_VALIDENTER;
_PAINTcontainer constr.CHATwindow_window_object_container;
//PluginRegisterAction inst "Destroy" mkfun6 @cbDestroy constr;
setPluginInstanceCbDel inst mkfun2 @deleteOb constr;
);
0;;
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Offline
and an indentation is done !
Yes I cleaned it up s bit.
Offline
Here is a scene that has two instances of the plugit...I linked them so you could pass strings from one window to the other, but something isn't happening and the string is not being passed.
http://www.ifam.net/chatwindow2/web/index.html
here is the xml code.perhaps it's missing some tags?
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<PLUGIN name="chatwindow" version="1.0" type="misc">
<DESCRIPTION>Chat Window Plugit</DESCRIPTION>
<HELP>Template plugIT help</HELP>
<EDITOR>
<SCRIPT path="./echatwindow.pkg" />
<PARAM name="oninit" type="value" />
</EDITOR>
<CLIENT minstance="true">
<SCRIPT path="./cchatwindow.pkg" />
<ACTION name="Print Incoming Message">
</ACTION>
<EVENT name="Send Outgoing Message">
</EVENT>
</CLIENT>
</PLUGIN>
here is the updated client code, including code for the action and event..I must be missing something here.
//struct definition
struct Chatwindow = [
CHATwindow_plugin_instance : PInstance,
CHATwindow_window_object_container : ObjContainer,
CHATwindow_parent_chat_window : ObjWin,
CHATwindow_chat_font : ObjFont,
CHATwindow_ongoing_chat_textfield : CompText,
CHATwindow_chat_entry_textfield : CompText
]mkChatwindow;;
fun printmessage(constr, value)=
_ADDcompText constr.CHATwindow_ongoing_chat_textfield strcatn value:: "":: "\n"::nil constr.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer constr.CHATwindow_window_object_container;
0;;
fun cbprintmessage(inst, from, action, param, reply, constr)=
printmessage constr param;
0;;
fun cbDestroy(inst, from, action, param, reply, constr)=
_DScompText constr.CHATwindow_ongoing_chat_textfield;
_DScompText constr.CHATwindow_chat_entry_textfield;
_DSfont constr.CHATwindow_chat_font;
_DScontainer constr.CHATwindow_window_object_container;
_DSwindow constr.CHATwindow_parent_chat_window;
0;;
fun deleteOb(inst, constr)=
cbDestroy inst nil nil nil nil constr;
0;;
//add text to ongoing_chat_textfield here
fun addtext(textobject, user_parameter,type,value)=
//update contents of chat interface
let ""-> empty_text_value in
(
_ADDcompText user_parameter.CHATwindow_ongoing_chat_textfield strcatn value:: "":: "\n"::nil user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_END;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
_SETcompText textobject "" user_parameter.CHATwindow_chat_font [0x00FFFF 0 0 0xFFFF00] CT_BEGIN;
_PAINTcontainer user_parameter.CHATwindow_window_object_container;
//code to send value of added text to other plugits as the parameter
_DMSevent this (getPluginInstanceEvent user_parameter.CHATwindow_plugin_instance "Send Outgoing Message") value nil;
0;
);
0;;
///create plugit function
fun newOb(inst)=
let _CRwindow _channel nil 0 450 800 150 WN_NOBORDER|WN_CHILDINSIDE "A window" -> thisparentchatwindow in
let _CRcontainerFromObjWin _channel thisparentchatwindow 0 0 800 150 CO_CHILDINSIDE 0x000000 "hackerwindow" -> thiscontainer in
//let......code here to make fatherwindow here -> thisfatherwindow in
let _CRfont _channel 12 0 0 "Lucida Console"-> thisfont in
let _CRcompText _channel thiscontainer nil [0 101] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_WORDWRAP|CT_EDITLINE 0 800 50 "text entry field" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil -> thistextentryfield in
let _CRcompText _channel thiscontainer nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|CT_LEFT|CT_LABEL|CT_WORDWRAP|CT_LABEL|CT_SELECT OBJ_CONTAINER_KEYDOWN 800 100 strcat "text entry here" "\n" thisfont [0x00FFFF 0 0 0xFFFF00] [0xFFFFFF 50] nil nil-> thisongoingchatfield in
let mkChatwindow [inst thiscontainer thisparentchatwindow thisfont thisongoingchatfield thistextentryfield]->constr in
(
_CBcompTextValidation constr.CHATwindow_chat_entry_textfield @addtext constr CT_VALIDENTER;
_PAINTcontainer constr.CHATwindow_window_object_container;
//code to set action function
PluginRegisterAction inst "Print Incoming Message" mkfun6 @cbprintmessage nil;
//PluginRegisterAction inst "Destroy" mkfun6 @cbDestroy constr;
setPluginInstanceCbDel inst mkfun2 @deleteOb constr;
);
0;;
fun IniPlug(file)=
PlugRegister @newOb nil;
setPluginEditor @dynamicedit;
0;;
Offline
it works! thanks.
no about the window order. when the windows are created, they are created behind the browser....is there a way to make them pop up in front of the browser?
the same behavior shows up in the os3d editor.
Offline
the main window being the os3d window?
Offline
yes
thx
Offline