[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-gtk-general
Subject:    [PHP-GTK] How to control focus "manually"
From:       "Paulo Bernardo Lindoso (UOL)" <pbal () uol ! com ! br>
Date:       2003-10-31 16:12:15
[Download RAW message or body]

Hello All,

I'm writing an order processing application in PHP-GTK and I'm having 
problems controlling form flow.

My form was designed to respect GTK's tab order - since there's no way 
to set it programatically, but at one stage, I want my customer to type 
in a product code and all its details are displayed automatically to 
make insertion easier.

I am doing this by trapping the "focus_out_event" signal.  Once the 
customer types in the code and move to the next field, the program 
performs a "select" on the database, grabs all relevant data and fills 
the other fields.  This is working perfectly.  The problem is that I 
want it to become a "loop", that is:

1. Type in product code;
2. Auto-fill description and unit price
3. Type in quantity
4. Auto-fill Total price for particular item;
5. Click "Insert" button
6. Program populates a a GTKCList;
7. Program moves back to (1) (ie. reset focus to product code field)

The above loop can only be left by clicking the "Finish Order" button, 
which calls the database insert subroutine.

My problem is step (7).  I'm using the "set_focus($widget)" function, 
which is called just after the "append" method to perform (6).  However, 
when I do that, it seems that the "focus_out_event" is triggered and the 
program begins to populate the GTKCList continuously until the app crashes.

Any ideas?

TIA,
Paulo.

Below parts of the code:
--------------------------------------------------
# function that performs the "append"...

function adicionaproduto() {
  
   $hndVenda=$GLOBALS["emporio"];
  
   $unitario=$hndVenda->arWidgets["txtPU"]->get_text();
   $qtde=$hndVenda->arWidgets["txtQtd"]->get_text();
   $total=$unitario*$qtde;
   $desc=$hndVenda->arWidgets["txtDesc"]->get_text();
   $codprod=$hndVenda->arWidgets["txtCP"]->get_text();
   $toappend=array($codprod,$qtde,$desc,$unitario,$total);
   $hndVenda->arWidgets["tblProd"]->append($toappend);
  
   $totalfinal=$hndVenda->arWidgets["txtTotal"]->get_text();
   $totalfinal+=$total;
   $hndVenda->arWidgets["txtTotal"]->set_text($totalfinal);
  
   $hndVenda->arWidgets["txtPU"]->set_text("");
   $hndVenda->arWidgets["txtQtd"]->set_text("");
   $hndVenda->arWidgets["txtDesc"]->set_text("");
   $hndVenda->arWidgets["txtCP"]->set_text("");
# $hndVenda->wndVenda->set_focus($hndVenda->arWidgets["txtCP"]);  CRASHES!
  
}

# callback function for "focus_out_event", quantity field...
    function on_txtQtd_lostfocus()
    {
        adicionaproduto();
        //$this->wndVenda->set_focus($this->arWidgets["txtCP"]);
    }

-- 
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic