GET Class

GET Class

Postby xProgrammer » Thu Mar 27, 2008 10:27 am

Hi Antonio

I want to try to fix a few aspects of the way GETs operate. Basically where the cursor goes and how selections are handled. I looked at the source code in get.prg and noticed the following

Code: Select all  Expand view
METHOD GotFocus() CLASS TGet

   ::SetPos( 0 )
   ::SetSel( 0, 0 )

return nil


but I can't see ::SetPos() or ::SetSel() declared in TGet or TControl or TWindow. Have I just missed it or what?

Currently the cursor goes to the end of the text (including the blanks) and selections are ignored.

By the way do you call

Code: Select all  Expand view
void                gtk_entry_set_max_length            (GtkEntry *entry,
                                                         gint max);


anywhere in your code? Do you set it based on the length of the variable in the associated GET? Do we in reality need an associated GET?

Thanks
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Fri Mar 28, 2008 10:28 am

Doug,

Those methods are defined in the Class header as INLINE methods.

The reason to use a GET variable is to be able to use the Clipper (Harbour) formats of the GET when using PICTUREs.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41291
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xProgrammer » Fri Mar 28, 2008 11:44 am

Hi Antonio

Thanks for your reply. I have been studying get.prg and I think I understand why blocked text is not being treated as such.

Look at the KeyDown( nKey ) method of class TGet.

Take a back space event as an example. The code calls the BackSpace() method of the associated GET object. This "moves the cursor to the left and deletes a character". But if the user has blocked a section of the text the whole section should be deleted.

A similar argument applies, I think, to your otherwise clause.

I think you need to add a HB_FUNC( GETGETSEL ) to gets.c based on gboolean gtk_editable_get_selection_bounds (GtkEditable *editable,
gint *start,
gint *end);
with a corresponding GetSel() method in your TGet class which could be called as part of the BackSpace and Otherwise clauses of the DO CASE in KeyDown( nKey ).

If I am right (and I quite possibly am totally wrong) that would fix one of my two problems with GETs as they currently operate.
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby xProgrammer » Sat Mar 29, 2008 2:22 am

Hi Antonio

Another suggestion for a change that might improve the operation of the TGet Class.

The line:

Code: Select all  Expand view
::SetText( If( ! ::lPassword, ::oGet:buffer, Replicate( "*", Len( AllTrim( ::oGet:buffer ) ) ) ) )


that occurs for both Back Space and Otherwise cases in the KeyDown( nKey ) method of class TGet might be better

Code: Select all  Expand view
::SetText( If( ! ::lPassword, RTRIM(::oGet:buffer), Replicate( "*", Len( AllTrim( ::oGet:buffer ) ) ) ) )


Hopefully this might stop us from tabbing to the end of a GET past where the meaningful text is.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby xProgrammer » Sat Mar 29, 2008 2:28 am

Hi Antonio

Is it possible for me to rebuild the ?library? from a modified c source (eg if I change gets.c) ? If so and you tell me how to do it, I can experiment with some of my suggestions and report back to you.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Sat Mar 29, 2008 8:59 am

Doug,

You can compile a C file this way:
gcc `pkg-config --cflags gtk+-2.0` -I./../harbour/include -I./include -Wall -c -o file.o file.c

And replace it in the library this way:
ar rc ./lib/libfivec.a file.o
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41291
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Some Progress

Postby xProgrammer » Sun Mar 30, 2008 12:10 am

Hi Antonio

1. I modified the TGet class so that it applied RTrim to oGet:buffer in four places:

the new() method

the K_BS case of the KeyDown() method

the K_DEL case of the KeyDown() method

the otherwise case of the KeyDown() method

This significantly improves behaviour when tabbing into a GET. Now the cursor position on entering a GET via a tab is at the end of the non-blank text (which is OK).

2. Whilst the GotFocus() method of the TGet class is clearly called when the event fires, neither ::SetPos( 0 ) nor ::SetSel( 0, 0 ) are working because the cursor stays at the end of the (now non-blank) text and the selection is the whole of the (now non blank) text. Note that the selection is not effective because the TGet class doesn't take it into account at this stage.

We need to fix SetPos() and SetSel() before we fix the operation of selection which will require a GetSel() function.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 3 guests