PDA

View Full Version : Commands in RichText?


ConndoR
06-30-2008, 05:35 AM
Is it possible to create some commands in RichText
for ex. when u will type /quit the application will exit when u type /minimize the application will minimize etc.

Imagine Programming
06-30-2008, 08:15 AM
well... if you had a one line richtext you could do this


--On Key event of richtext

if(e_Key==13)then
sCommand=RichText.GetText(this, false);
if(sCommand=="/quit")then
Application.Exit(0);
elseif(sCommand=="/minimize")then
Application.Minimize();
else
Dialog.Message("Error", "Unrecognized command!");
end
RichText.SetText(this, "", false);
end

ConndoR
06-30-2008, 09:33 AM
well... if you had a one line richtext you could do this


--On Key event of richtext

if(e_Key==13)then
sCommand=RichText.GetText(this, false);
if(sCommand=="/quit")then
Application.Exit(0);
elseif(sCommand=="/minimize")then
Application.Minimize();
else
Dialog.Message("Error", "Unrecognized command!");
end
RichText.SetText(this, "", false);
end


it's not working :(
when i type /quit or /minimize it says Unrecognized command! :(
Help!

Imagine Programming
06-30-2008, 02:12 PM
no not when you type but after you've pressed enter...

besides that type it right... cos it works fine with me...

ConndoR
07-01-2008, 01:25 AM
no not when you type but after you've pressed enter...

besides that type it right... cos it works fine with me...

I pressed Enter also when i typed /quit but it's showing that message :(

ConndoR
07-01-2008, 08:44 AM
can u post it as an example then maybe it should work

longedge
07-01-2008, 09:35 AM
Just guessing, 'On Key' events usually occur as soon as a key has been pressed so the first character would trigger the event wouldn't it?

Imagine Programming
07-01-2008, 12:21 PM
Just guessing, 'On Key' events usually occur as soon as a key has been pressed so the first character would trigger the event wouldn't it?

i've put if(e_Key==13)then in there... so it'll only fire on Pressing return/enter

if(e_Key==13)then --Checking if Enter/Return == pressed
sCommand=RichText.GetText(this, false);
sCommand=String.Replace(sCommand, "\r\n", "", false)
if(sCommand=="/quit")then
Application.Exit(0);
elseif(sCommand=="/minimize")then
Application.Minimize();
else
Dialog.Message("Error", "Unrecognized command!");
end
RichText.SetText(this, "", false);
end

Imagine Programming
07-01-2008, 12:28 PM
Here you go... example :)

longedge
07-01-2008, 12:32 PM
i've put if(e_Key==13)then in there... so it'll only fire on Pressing return/enter

Ah.. yes sorry, I should've checked the virtual key codes.

ConndoR
07-03-2008, 09:22 AM
thnx now it's working

Imagine Programming
07-03-2008, 12:08 PM
Ah.. yes sorry, I should've checked the virtual key codes.

Ah well don't worry, i had a delete function in a listbox once but i forgot its keycode... so on every key i deleted an item in the listbox :lol