Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sat Oct 20, 2018 3:54 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Hotkeys in datagrids
PostPosted: Mon Jun 19, 2006 9:50 am 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
Is there a way to use a hotkey when in an editable data grid? I put in a breakpoint but it didn't seem to be executing that code when the hotkey was pressed.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 9:57 am 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
I have been told that apparently we have altered the object to make it editable... so I'm guessing you guys can't help on this one.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 10:01 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Well, part of this depends on how you edited the data grid to allow editing.



If you modified the DG to fit inside the framework that the other objects use for keypad entry, then you may just need to increase the priority variable on the hot key object.



If you modified the DG to directly handle the key messages, instead of the bid won message, then there may be more you need to do.



Good luck. Hopefully whoever modified the object can help shed some light here.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject: question
PostPosted: Mon Jun 19, 2006 10:18 am 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
private func InsertText( row as integer, col as integer, text as string )



if not isEditable then

return

endif

if textEditMode then

' Only allow 5 characters per cell (65535 is max val)

if Len( GetCellText( row, col ) ) > 4 then

return

endif

SetCellText( row, col, GetCellText( row, col ) + text )

else

SetCellText( row, col, text )

textEditMode := true

endif

endfunc





I think that is what he used to make it editable (it was a developer who just kinda left and didn't document anything).



Is there a way to detect if it was a + or a - and somehow trigger the hotkey for + and -? This would be acceptable behavior since the domain of the object is 0-9.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 10:22 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
That function you posted is helpful, and likely one of the helper functions your developer used. What I really need is to know how your data grid is getting it's key strokes, which your code snippet doesn't answer. In other words, what is calling the InsertText function.



I am beginning to wonder if there is another hotkey object which is handling all keys and routing the number keys to the datagrid object. In that case, the all keys hotkey object would probably "steal" the keystroke from the hotkey object you are using. Also, in this case, you just need to add your handling for the + and - key to this other hotkey object.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject: question
PostPosted: Mon Jun 19, 2006 11:07 am 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
Do you know where I can obtain a list of the different symbols like:

KEY_ANY

_kt_keyId

MSG_ZENABLED

?



Sorry for all the questions... I'm an intern working on this project



Thanks for all the help though. This is amazing service.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 11:48 am 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
I've been trolling around the site... can't seem to find any of this


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 12:03 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
The sample items you listed cover a broad range. My first resort would be the search function of the online help (F1).



You can find KEY_ANY along with all other defined key symbols there.



_kt_keyID is used internally by the keypad sub-system and is not documented.



Finally, MSG_ZENABLED is a system message and should be described in the programmer's reference.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 12:06 pm 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
registerKey(me, KEY_ANY)



I think this is what is causing it... is there a way to somehow specify:

Key_ANY & ~(KEY_PLUS) & ~(KEY_MINUS)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 12:12 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Unfortunately no. Those are enumerated values and not bit flags.



From what little bit I have gleaned from your code, you will have to probably find whatever is calling InsertText and add some checks there:



Code:

' Inside some key related function, I am guessing.



... 'existing code

if (keycode and keyascii) == '+' then

   'Handle the plus code

elseif (keycode and keyascii) == '-' then

   'Handle the minus code

else

   'Copy the existing call to InsertText here

endif


_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 12:51 pm 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
I can register everything individually that I need except I am not sure how I would register the number pad.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 1:02 pm 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Well, registering individually could be problematic as well. Each object can register for exactly one key (or all keys using KEY_ANY). Subsequent calls to RegisterKey will overwrite the previous one.



In general, I would strongly recommend against ever registering for a specific key. This is because it traps against key flags. For instance, if the '9' key were pressed while the shift key were active, the terminal would return for its keycode the value of ('9' or KEY_SHIFT). Had your object called RegisterKey('9'), then your object would not receive the event notification as the key code does not exactly match what you registered for.



The correct behavior if (and only if) you are processing key messages outside the key framework of our objects which handle keys, is to check the keycode in the key message handler. If you are not interested in handling that key, your key message handler should return false. If you are interested in that key and don't want anyone else to process it as well then return true.



I think that there may be something here that I am missing as you seem reluctant to simply add the '+' and '-' key processing in the same place as the other keys are being processed in the datagrid.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 6:27 am 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
private func KeyPress (keycode as unibyte) returns boolean

handles MSG_KEY_PRESS

_KT_Bid(me, myPriority, MsgType_KeyPress)

return false

endfunc



I believe this is the function you're talking about.



I put in a breakpoint to see what the value of the unibyte was for + and -

they appeared to be 32778 and 32779



I put in code as follows:



private func KeyPress (keycode as unibyte) returns boolean

handles MSG_KEY_PRESS

if (keycode == 32778 or keycode == 32779)

return false

endif

_KT_Bid(me, myPriority, MsgType_KeyPress)

return false

endfunc





That didn't seem to work.



Am I misunderstanding the way this functions? I would think that when a key gets pressed when this object is selected, it would get called and if it returns false, it will "release" that keystroke to the rest of the program for handling. I expect it to send a request to use that keystroke if it is not + or -. I noticed that it does execute the return false.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 6:41 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Please understand I am flying blind. You appear to have a custom modified object and I am not privy to its code.



If the MSG_KEY_PRESS function looks like that, then it appears that someone has hooked into our key framework. In that case, there should be a "BidWon" or _MSG_BID_WON or something like that in the same object. That function will contain the code that you need to handle. In particular, it should contain the code which calls InsertText.



As far as I have been able to gather, what you have is a custom data grid which is claiming all key strokes. The data grid appears to have been modified to at least partially fit in the key bidding framework used by the standard key enabled objects. However, it is claiming the key presses even over a hot key object with a high priority. In particular, something is grabbing the + and the - keys and forwarding them to the DataGrid.InsertText function. As this function is private to the custom data grid, I assume that this must be in the data grid itself.



I could easily have missed something here. Your options as I see them are to fix the data grid to not claim hotkey priority key presses, or if you are interested in custom processing of the + and the - keys when the keypad, then figuring out where InsertText is being called and placing the trap right there.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 20, 2006 6:54 am 
Offline

Joined: Wed Jun 14, 2006 12:28 pm
Posts: 13
There is a bidwon function. So once the bid is won, the keystroke cannot be sent out to the system to be claimed for handling correct?





For reference:

protected func BidWon(ktype as integer) returns boolean

handles MSG_KT_BIDWON



'27JAN2006 - KMC - Adding text editing capabilities

dim cellTxt as charstr

cellTxt := GetCellText( curRow, curCol )



'key_space & key_backspace not need in a listbox, change

'behavior of those keys to act like key_escape & key_enter.

if _kt_keyID == KEY_ENTER or _kt_keyID == KEY_ESCAPE or _kt_keyID == KEY_SPACE or ->

_kt_keyID == KEY_DELETE or _kt_keyID == KEY_BACKSPACE then

if (ktype == 1) or ->

(ktype == 0) then

return true

endif

else

if ktype <> 1 then

return true

endif

endif



if !editMode then

' check if direction to change focus

if _keySetMoveFocus(_kt_keyID) then

return true

endif

endif

if editMode then

if _kt_keyID == KEY_ENTER or _kt_keyID == KEY_ESCAPE or _kt_keyID == KEY_SPACE or ->

_kt_keyID == KEY_BACKSPACE then

if _kt_keyID == KEY_ESCAPE then

'editMode = false

textEditMode = false

currow = oldselrow

curcol = oldselcol

MakeCellVisible (curRow, curCol)

Cancel()

return true

endif

if _kt_keyID == KEY_ENTER or _kt_keyID == KEY_SPACE then

'editMode = false

textEditMode = false

DblClick()

return true

endif

if _kt_keyID == KEY_DELETE or _kt_keyID == KEY_BACKSPACE then

' 27JAN2006 - KMC - Moved KEY_DELETE and KEY_BACKSPACE to their

' own handler -- was grouped with KEY_ESCAPE

if Len( cellTxt ) > 0 then

SetCellText( curRow, curCol, Left( cellTxt, Len( cellTxt ) - 1 ) )

Rerender( me )

endif

endif

'elseif _kt_keyID == KEY_LEFTARROW then

'if curcol > 0 then

' curcol = curcol-1

' MakeCellVisible (curRow, curCol)

'endif

'elseif _kt_keyID == KEY_RIGHTARROW then

'if curcol < numcolumns-2 then

' curcol = curcol+1

' MakeCellVisible (curRow, curCol)

'endif

elseif _kt_keyID == KEY_UPARROW then

if currow > numfixedrows then

currow = currow - 1

textEditMode = false

MakeCellVisible (curRow, curCol)

endif

elseif _kt_keyID == KEY_DOWNARROW then

currow = currow + 1

textEditMode = false

MakeCellVisible (curRow, curCol)

elseif _kt_keyID == KEY_PAGEDOWN then

currow = currow + ((height-2*borderWidth-(numfixedrows*cellheight))/cellHeight)

MakeCellVisible (curRow, curCol)

elseif _kt_keyID == KEY_PAGEUP then

currow = currow - ((height-2*borderWidth-(numfixedrows*cellheight))/cellHeight)

if currow < numfixedrows then

currow = numfixedrows

endif

MakeCellVisible (curRow, curCol)

else

if _kt_keyID == KEY_0 then

InsertText( curRow, curCol, "0" )

elseif _kt_keyID == KEY_1 then

InsertText( curRow, curCol, "1" )

elseif _kt_keyID == KEY_2 then

InsertText( curRow, curCol, "2" )

elseif _kt_keyID == KEY_3 then

InsertText( curRow, curCol, "3" )

elseif _kt_keyID == KEY_4 then

InsertText( curRow, curCol, "4" )

elseif _kt_keyID == KEY_5 then

InsertText( curRow, curCol, "5" )

elseif _kt_keyID == KEY_6 then

InsertText( curRow, curCol, "6" )

elseif _kt_keyID == KEY_7 then

InsertText( curRow, curCol, "7" )

elseif _kt_keyID == KEY_8 then

InsertText( curRow, curCol, "8" )

elseif _kt_keyID == KEY_9 then

InsertText( curRow, curCol, "9" )

endif

endif

else

if _kt_keyId == KEY_ENTER or _kt_keyID == KEY_SPACE then

editMode = true

endif

endif

return true

endfunc


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group