Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 112
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - passing a value from a gadget to a form

passing a value from a gadget to a form

Discuss topics that apply across the products, such as the PocketC language, or development in general

Postby johncraw on Tue Nov 21, 2006 2:57 pm

I have a gadget that acts like a calculator. I would like to be able to pass a value from the gadget to a field on the form.
If I try "fldIN.text = CalcValue" fldIN is undeclared when I try to compile
If I try "mainForm.fldIN.text = CalcValue" mainForm is undeclared when I try to compile.

Is there any way that I can pass the value automatically?

Thanks in advance
John Crawford
johncraw
 
Posts: 64
Joined: Mon May 24, 2004 11:39 am
Location: Canada

Postby mlambrigger on Tue Nov 21, 2006 3:13 pm

You must have one of the propriety of the gadget that is the result of the claculation, example:

Code: Select all
fldIN.text = CalcValue.result


As the gadget is part of the form, you can access the proprieties of your gadget from the form.

the second possibilty is to have a global in your form. As the gadget is linked to your form, you have access to the globals of the form, where your gadget will store the result. This second option is not good at all, cause you need a global each time you use your gadget.

Marc Lambrigger
Marc Lambrigger
mlambrigger
 
Posts: 113
Joined: Fri Feb 13, 2004 11:07 am
Location: Switzerland

Postby johncraw on Wed Nov 22, 2006 8:52 pm

Marc:
Thanks. I thought of those possibilities. However neither do what I want. Both have the form getting the value from the gadget (or global). What I want is to select an area in the gadget, and have that populate the field in the form. So instead of the form controlling it, I want the gadget to control it.
John
johncraw
 
Posts: 64
Joined: Mon May 24, 2004 11:39 am
Location: Canada

Postby mlambrigger on Thu Nov 23, 2006 6:51 am

OK, I see, try this:

on the form, I have a field, a label and a gadget. The files are the followings:
Code: Select all
// application code

handler app.onstart() {
   // load the main form
   mainForm.load();
}
<hr noshade size="1">
Code: Select all
// mainform.oc
// Created for mainForm

void affiche(int posX, int posY){
   alert(posX + " " + posY);
}

handler mainForm.onopen() {
   // TODO: handle onopen event
   gadget1001.frame = affiche;
}
<hr noshade size="1">
Code: Select all
// gadget.oc
funcptr Modifie void(int, int);

struct Chart {     // NOTE: As of version 3 this must be a struct
  UIGadget gadget; // rather than an object
  void onopen();
  void ondraw();
  void onpenmove();
  void defineForm(Modifie form);
 
  Draw draw;
  Modifie frame;
};

void Chart.onopen(){
   draw.attachGadget(gadget);
}

void Chart.onpenmove(){
   draw.begin();
   draw.rect(1, 0, 0, gadget.w-1, gadget.h-1, 0);
   draw.line(0, 0, 0, gadget.w-1, 0);
   draw.line(0, gadget.w-1, 0, gadget.w-1, gadget.h-1);
   draw.line(0, gadget.w-1, gadget.h-1, 0, gadget.h-1);
   draw.line(0, 0, gadget.h-1, 0, 0);
   //draw.rect(1, 1,1,gadget.w-1, gadget.h-1,0);
   draw.line(255, event.x-2, event.y,event.x+2, event.y);
   draw.line(255, event.x, event.y-2, event.x, event.y+2);
   frame(event.x, event.y);
   draw.end();
}

void Chart.ondraw(){
   draw.begin();
   draw.rect(1, 0,0,gadget.w, gadget.h,0);
   draw.end();
}


I think this will resolve your problem. let me know.

Marc Lambrigger
Marc Lambrigger
mlambrigger
 
Posts: 113
Joined: Fri Feb 13, 2004 11:07 am
Location: Switzerland

Postby johncraw on Thu Nov 23, 2006 7:36 pm

Marc:
Once again thank you.
Now if I can just get it to work!
I follow the logic, and entered your code. It worked fine.
The function affiche receives the values from the gadget, and the alert displays them. Right?
So what I did was added fldOut and lblOut, and after the alert I added:
fldOut.text = posX + " " + posY;
lblOut.text = posX + " " + posY;

However wnhen I run it I get nothing in the two fields!!

So I thought to myself Self isolate it, so I now have the following code:

int x;
int y;

void Displayit()
{
alert("Got here" + x + " " + y);
fldOut.text = x + " X " + y;
lblOut.text = x + " X " + y;
}

void affiche(int posX, int posY)
{
x = posX;
y = posY;

alert(x + " " + y);
Displayit();
}

The alert in Displayit does display the data correctly, so the x and y variables are being populated correctly.
The fields, however still show nothing.
I do not know what I am doing wrong, but it is frustrating. It is probably something obvious, and simple. I can't see the forest for the trees.
John
johncraw
 
Posts: 64
Joined: Mon May 24, 2004 11:39 am
Location: Canada

Postby mlambrigger on Fri Nov 24, 2006 11:09 am

Hello, I found what is missing!!

rewrite your event like this:

Code: Select all
void Displayit()
{
alert("Got here" + x + " " + y);
fldOut.text = x + " X " + y;
lblOut.text = x + " X " + y;
// alert(ldlOut.text);  // this to test the text value of lblOut and fldOut
mainForm.redraw(0); // mainForm the form where the fields are.
}


I think the gadget has his own drawing thread, so when there is a change in the gadget, the gadget and only this will be redrawn. To draw the change in the fields, you must redraw the form.

Hooping this will help you.

Marc Lambrigger
Marc Lambrigger
mlambrigger
 
Posts: 113
Joined: Fri Feb 13, 2004 11:07 am
Location: Switzerland

Postby johncraw on Fri Nov 24, 2006 5:52 pm

Marc:
Thanks again. It works great.
After I sent teh last update, I tried the alert of one of the values. That really made me crazy!! The redraw of the form gave me what I need.
John
johncraw
 
Posts: 64
Joined: Mon May 24, 2004 11:39 am
Location: Canada


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron