MsgBox2 Problem

Tom Law

Active Member
Licensed User
Longtime User
I am trying to construct a row deletion routine for my datagrid. The user selects a row for deletion, this highlights the row and the user is requested to 'Confirm Deletion'. After clicking a suitable response from the msgbox2 message box there is a long delay followed by a system message that complains that my application is not responding.

Upon clicking the system message wait option the program comes back to life again. The routine below shows how I am using Msgbox2 - can anyone suggest why I am getting this problem (or is this a msgbox2 bug).

'Confirm request to delete a datagrid row -----------------------------------

Select Msgbox2("Delete this appliance - are you sure", "Please confirm Deletion","Yes","","No",Null)

Case DialogResponse.NEGATIVE
WriteGridData 'refresh datagrid
Case DialogResponse.POSITIVE
eqptcursor.Position = RowNo 'Set the cursor to the row being editted
Dim myID As Int
myId = eqptCursor.GetInt ("_Id")
SQL1.ExecNonQuery("Delete from Equipment where _Id = " & myId)
EqptCursorRefresh
WriteGridData 'refresh datagrid

End Select
'--------------------------------------------------------------------------

:sign0104:
 

stevel05

Expert
Licensed User
Longtime User
The first thing I would try would be to assign the result of the message box to a variable and use that in the select statement.

If that doesn't improve things, I would replace the processing from the case statements with just a log(response) or similar, and see what happens.

After that I would look at the code in WriteGridData to see if there is the possibility of looping for whatever reason.

But you could also check the log filtered and unfiltered, to see if there are any relevant messages there.

Hope this helps.
 
Upvote 0

Tom Law

Active Member
Licensed User
Longtime User
Hi Steve,

Thank you for your help. To try to resolve this I placed breaks on both lines where values are returned from msgbox2. In both cases the lines were not being hit until after the unresponsive message was cleared.

The problem definately seems to be isolated to msgbox2. The program is running on a brand new Motorola Xoom which has behaved faultlessly up to now so either I am using the function incorrectly or there is a bug in the msgbox2 command.

I had previously tried your other suggestion of assigning a variable to catch the returned option but got the same result.

Appreciate your suggestions


Tom
 
Upvote 0

myriaddev

Active Member
Licensed User
Longtime User
Try this idea

Dim int1 As Int
int1 = Msgbox2(...)
Select int1
Case ...
Log("...")
Case ...
Log("...")
...
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Hi Tom,

I can't reproduce the problem on my HTC Hero, have you tried your app on the emulator?

Steve
 
Upvote 0

Tom Law

Active Member
Licensed User
Longtime User
Hi myriaddev, thank you for the suggestion, unfortunately I got the same result.

Steve that sounds like a good idea - I will try it with the emulator and let you know how I get on.
 
Upvote 0

Tom Law

Active Member
Licensed User
Longtime User
Hi Erel,

Thanks for the advice (I had'nt previously used the unfiltered logs - lots of useful info there). Unfortunately I did'nt understand it well enough to diagnose the problem. I am developing the program on a Motorola Xoom under Android 3.2 - the same error occurs on the emulator. If anyone would like to give me the benefit of their advice I have attached a copy of the program. To duplicate the error:

1) Start up the program
2) Click on Service Details tab (datagrid is here).
3) Highlight a row by clicking the grey bar on the right of the grid.
4) The messagebox pops up then causes the system to hang until another system message has been dismissed.

I have been on with this problem all day but being a new user I am probably missing something obvious.

Tom
 

Attachments

  • Zip8.zip
    46 KB · Views: 236
Upvote 0

Tom Law

Active Member
Licensed User
Longtime User
Small correction

Highlight a row by clicking the grey bar at the, left, side of the datagrid.
:signOops:
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see this too. The problem is that you are trying to show a modal dialog inside a Touch event. Unlike Click events, Touch events fire multiple times.
You have several options:
- Change to Click event.
- Use a Timer to delete the timer. The timer allows the touch messages to be processed properly.

B4X:
Sub GridPanel_Touch (Action As Int, X As Float, Y As Float) As Boolean              
'DATAGRID SUB ROUTINE(11)         
'Get the Cell co-ordinates
If Action <> Activity.ACTION_DOWN Then Return True '!!!!!!!!!!!!!!!!!!
Dim Temp As Int
Temp = EqptCursor.Position
If EditText1.Visible Then EditText1_EnterPressed  'Take care of any outstanding edits before proceeding
Edittext1.Text=""

'get cell left
Dim Count As Int 
For Count = 0 To 13
   
   If X > ColLine(Count) Then 
      CellLeft = ColLine(Count)
      CellWidth = ColLine(Count+1)-ColLine(Count)
      ColNo = Count
   Else
      Exit
   End If

Next
      Dim Temp As Int 
'get cell top
For count=1 To (GRID_ROWS + 1) 'RowHeaders plus total GRID_ROWS

   If  Y > (gridFieldHeight * count) Then 
      Celltop = gridFieldHeight * count
      RowNo = Count - 1
      eqptCursor.Position = Topline + Rowno
   Else
      Exit
   End If

Next
   
If CellLeft > 1 Then
   Gridedit
Else
   deleteTimer.Enabled = True
End If
   Return True
End Sub
Sub DeleteTimer_Tick
   deleteTimer.Enabled = False
   DeleteLine
End Sub
Sub DeleteLine                                                                     
'DATAGRID SUB ROUTINE(12)
'Delete a datagrid data record

'Shade selected row 
...

The timer should be declared in Process_Globals and initialized in Activity_Create:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
   deleteTimer.Initialize("DeleteTimer", 1)
End If

Note that there are several simpler implementations of tables based on labels and a scrollview. I recommend you to use one of those examples instead.
 
Upvote 0
Top