Error within BASIC class, New() method

Moderator: Rathinagiri

User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Error within BASIC class, New() method

Post by concentra »

In the following code:

Code: Select all

#include "hmg.ch"

/***********************************/
FUNCTION Main()
/***********************************/

   LOCAL oWindow
   LOCAL oToolBar
   LOCAL oButton1

   HbQt_ErrorSys()

   WITH OBJECT oWindow := Window():New()

      WITH OBJECT oToolBar := ToolBar():New()

         WITH OBJECT oButton1 := ToolButton():New("oButton1")
            :Caption   := 'Call dialog'
            :OnClick   := { || CallDialog() }
         END WITH

      END WITH

   END WITH

   oWindow:Activate()

RETURN NIL



/***********************************/
STATIC FUNCTION CallDialog()
/***********************************/

   LOCAL oDlg
   LOCAL oButtonBox

   WITH OBJECT oDlg := Dialog():New( "oDlg" )
      :Width   := 200
      :Center()

      WITH OBJECT oButtonBox  := ButtonBox():New("oButtonBox")
         :addButton( BUTTON_OK    ,, { || oDlg:Accept() } )
         :addButton( BUTTON_CANCEL,, { || oDlg:Reject() } )
      END WITH

   END WITH

   oDlg:Activate()

RETURN NIL
If the button that calls the dialog is clicked more than one time I get an error:

error within BASIC class, New() method

And I was unable to find why...
[[]] Mauricio Ventura Faria
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Error within BASIC class, New() method

Post by mrduck »

The problem reported is a serious one...

you can temporary solve with
concentra wrote: WITH OBJECT oDlg := Dialog():New( )
but the underlying problem is more serious...
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Error within BASIC class, New() method

Post by concentra »

Francesco, I don't know if it's related but if the buttonbox is removed, another error rises, related to eventloop, when the dialog is closed.
[[]] Mauricio Ventura Faria
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Error within BASIC class, New() method

Post by mrduck »

concentra wrote:Francesco, I don't know if it's related but if the buttonbox is removed, another error rises, related to eventloop, when the dialog is closed.

Please, a code snippet... I've never used dialog.... ( I think to know what this problem is, but I need a piece of code to test)
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Error within BASIC class, New() method

Post by concentra »

mrduck wrote:Please, a code snippet... I've never used dialog.... ( I think to know what this problem is, but I need a piece of code to test)
The very same, without the buttonbox:

Code: Select all

#include "hmg.ch"

/***********************************/
FUNCTION Main()
/***********************************/

   LOCAL oWindow
   LOCAL oToolBar
   LOCAL oButton1

   HbQt_ErrorSys()

   WITH OBJECT oWindow := Window():New()

      WITH OBJECT oToolBar := ToolBar():New()

         WITH OBJECT oButton1 := ToolButton():New("oButton1")
            :Caption   := 'Call dialog'
            :OnClick   := { || CallDialog() }
         END WITH

      END WITH

   END WITH

   oWindow:Activate()

RETURN NIL



/***********************************/
STATIC FUNCTION CallDialog()
/***********************************/

   LOCAL oDlg
   LOCAL oButtonBox

   WITH OBJECT oDlg := Dialog():New( "oDlg" )
      :Width   := 200
      :Center()

//      WITH OBJECT oButtonBox  := ButtonBox():New("oButtonBox")
//         :addButton( BUTTON_OK    ,, { || oDlg:Accept() } )
//         :addButton( BUTTON_CANCEL,, { || oDlg:Reject() } )
//      END WITH

   END WITH

   oDlg:Activate()

RETURN NIL
[[]] Mauricio Ventura Faria
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Error within BASIC class, New() method

Post by mrduck »

With or without that lines the problem stays.... I understand it, I will fix later.
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Error within BASIC class, New() method

Post by concentra »

Another question...
Is keyboard navigation disabled by default in grids ?
I can't navigate using keyboard, only with mouse...

Code: Select all

#include "hmg.ch"
#include "hbqtgui.ch"

/*******/
FUNCTION Main()
/*******/

   LOCAL oWindow
   LOCAL oGrid
   LOCAL I
   LOCAL aStru := { { "FIELD1", "C", 12, 0 },;
                    { "FIELD2", "C", 12, 0 },;
                    { "FIELD3", "C", 12, 0 } }

   HbQt_ErrorSys()

   DBCREATE( "TESTE", aStru )
   USE TESTE
   FOR I := 1 TO 100
      DBAPPEND()
      TESTE->FIELD1 := "1111"
      TESTE->FIELD2 := "2222"
      TESTE->FIELD3 := "3333"
   NEXT
   GO TOP

   WITH OBJECT oWindow := Window():New()
      :Width   := 780
      :Height  := 500

      WITH OBJECT oGrid := VirtualGrid():New("oGrid")
         :Width     := 770
         :Height    := 490
         :WorkArea  := 'TESTE'
      END WITH

   END WITH

   oWindow:Activate()

RETURN NIL
[[]] Mauricio Ventura Faria
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Error within BASIC class, New() method

Post by Rathinagiri »

Nope. Keyboard navigation is not disabled by default.

However, cellnavigation is disabled by default in HMG3.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
concentra
Posts: 256
Joined: Fri Nov 26, 2010 11:31 am
Location: Piracicaba - Brasil

Re: Error within BASIC class, New() method

Post by concentra »

rathinagiri wrote:Nope. Keyboard navigation is not disabled by default.
It's related to Harbour build.

I returned a previous 3.1 Harbour version and the navigation is ok again.
[[]] Mauricio Ventura Faria
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Error within BASIC class, New() method

Post by mrduck »

Mauricio,
I have a set of commits to make, one solves this problem. DoKeyboardEvent in a point returns .T., change to .F.

An event that returns .T. stops the "event train", it means Qt doesn't handle the event... with .F. Qt handles the event...

In HMG4 Changelog this is described
Post Reply