Why my onTableReplaced is not called?

View: New views
5 Messages — Rating Filter:   Alert me  

Why my onTableReplaced is not called?

by Feng Feng :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello all,

I have designed a subclass of FXTable as follows,

The problem is that the function onTableReplaced is never triggered after I enter some text in the table and then press enter.

Do you know why?

Thank you


class PointTable : public FXTable
{
    FXDECLARE(PointTable )
    ...
    long onKeyPress(FXObject*,FXSelector,void*);
    long onTableReplaced(FXObject*,FXSelector,void*);
    ....
}


// Map
FXDEFMAP(PointTable ) PointTableMap[]={
    FXMAPFUNC(SEL_KEYPRESS,      0, PlanPointTable::onKeyPress),
    FXMAPFUNC(SEL_REPLACED,      0,PlanPointTable::onTableReplaced),

};

// Object implementation
FXIMPLEMENT(PointTable ,FXTable,PointTable Map,ARRAYNUMBER(PointTableMap))

// onKeyPress is triggered correctly.
long PlanPointTable::onKeyPress(FXObject *obj, FXSelector sel, void* ptr)
{
     if ( !isEditable() || current.col<0 || current.col >= ncols
         || current.row<0 || current.row >= nrows)
     {
         return 1;
     }
 
     if (current.col == 0 || current.col == 2)
     {
         return 1;
     }

    return FXTable::onKeyPress(obj, sel, ptr);
}

// Replaced
long PlanPointTable::onTableReplaced(FXObject*,FXSelector,void* ptr){
 
   //... NEVER get called after I enter some text and press ENTER
  
   
    return 1;      
  }



------------------------------------------------------------------------------

_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: Why my onTableReplaced is not called?

by Jeroen van der Zijp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 25 June 2009, Feng Feng wrote:

> Hello all,
>
> I have designed a subclass of FXTable as follows,
>
> The problem is that the function onTableReplaced is never triggered after I enter some text in the table and then press enter.
>
> Do you know why?
>
> Thank you
>
>
> class PointTable : public FXTable
> {
>     FXDECLARE(PointTable )
>     ...
>     long onKeyPress(FXObject*,FXSelector,void*);
>     long onTableReplaced(FXObject*,FXSelector,void*);
>     ....
> }
>
>
> // Map
> FXDEFMAP(PointTable ) PointTableMap[]={
>     FXMAPFUNC(SEL_KEYPRESS,      0, PlanPointTable::onKeyPress),
>     FXMAPFUNC(SEL_REPLACED,      0,PlanPointTable::onTableReplaced),
>
> };
>
> // Object implementation
> FXIMPLEMENT(PointTable ,FXTable,PointTable Map,ARRAYNUMBER(PointTableMap))
>
> // onKeyPress is triggered correctly.
> long PlanPointTable::onKeyPress(FXObject *obj, FXSelector sel, void* ptr)
> {
>      if ( !isEditable() || current.col<0 || current.col >= ncols
>          || current.row<0 || current.row >= nrows)
>      {
>          return 1;
>      }
>  
>      if (current.col == 0 || current.col == 2)
>      {
>          return 1;
>      }
>
>     return FXTable::onKeyPress(obj, sel, ptr);
> }
>
> // Replaced
> long PlanPointTable::onTableReplaced(FXObject*,FXSelector,void* ptr){
>  
>    //... NEVER get called after I enter some text and press ENTER
>    
>    
>     return 1;      
>   }

When acceptInput(true) is invoked via FXTable receiving ID_ACCEPT_INPUT from
the edit-control, it sends a SEL_REPLACED to its target.

It does NOT send a SEL_REPLACED to itself....


                - Jeroen

------------------------------------------------------------------------------
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: Why my onTableReplaced is not called?

by Feng Feng :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello Jeroen,

>When acceptInput(true) is invoked via FXTable receiving ID_ACCEPT_INPUT from
>the edit-control, it sends a SEL_REPLACED to its target.

>It does NOT send a SEL_REPLACED to itself....

Based on the feature, what is the best way to update the internal data-structure after the cell of the table has been updated.

For example:

After the user enters the text and presses ENTER or TAB, I want to be notified and update the internal data-structure accordingly.

Thank you



------------------------------------------------------------------------------

_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: Why my onTableReplaced is not called?

by Feng Feng :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hello Jeroen,

>When acceptInput(true) is invoked via FXTable receiving ID_ACCEPT_INPUT from
>the edit-control, it sends a SEL_REPLACED to its target.
>It does NOT send a SEL_REPLACED to itself....

If I change the acceptInput as follows:

// Done with editing cell
FXbool PlanPointTable::acceptInput(FXbool notify){
    if(editor){
        FXTableRange tablerange=input;
        setItemFromControl(input.fm.row,input.fm.col,editor);
        cancelInput();
        if(notify && target){
            //target->tryHandle(this,FXSEL(SEL_REPLACED,message),(void*)&tablerange);
            tryHandle(this,FXSEL(SEL_REPLACED,0),(void*)&current);  <========== modified!!!
        }
        return true;
    }
    return false;
}

Does this modification cause me problems in other places?

Thank you



------------------------------------------------------------------------------

_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users

Re: Why my onTableReplaced is not called?

by Jeroen van der Zijp :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 25 June 2009, Feng Feng wrote:

> Hello Jeroen,
>
> >When acceptInput(true) is invoked via FXTable receiving ID_ACCEPT_INPUT from
> >the edit-control, it sends a SEL_REPLACED to its target.
> >It does NOT send a SEL_REPLACED to itself....
>
> If I change the acceptInput as follows:
>
> // Done with editing cell
> FXbool PlanPointTable::acceptInput(FXbool notify){
>     if(editor){
>         FXTableRange tablerange=input;
>         setItemFromControl(input.fm.row,input.fm.col,editor);
>         cancelInput();
>         if(notify && target){
>             //target->tryHandle(this,FXSEL(SEL_REPLACED,message),(void*)&tablerange);
>             tryHandle(this,FXSEL(SEL_REPLACED,0),(void*)¤t);  <========== modified!!!
>         }
>         return true;
>     }
>     return false;
> }
>
> Does this modification cause me problems in other places?

The target of FXTable is supposed to receive SEL_REPLACED, etc. messages.  

Its probably easier to simply overload acceptInput() and call the base class:


        FXbool PlanPointTable::acceptInput(FXbool notify){
  if(FXTable::acceptInput(notify)){
                        // do your thing
                        return true;
                }
                return false;
        }


Or something to that effect.  Self messages shouldn't be necessary very often, btw.



                - Jeroen

------------------------------------------------------------------------------
_______________________________________________
Foxgui-users mailing list
Foxgui-users@...
https://lists.sourceforge.net/lists/listinfo/foxgui-users