cancel
Showing results for 
Search instead for 
Did you mean: 

How to prevent a cell from receiving focus ?

Former Member
0 Kudos

Hello,

I have a matrix with a column and two rows. The column is editable.

I want to prevent the user from inputting data into the cell of the first row.

I prevent access to that cell by stopping the click event,

however the user can "bypass it" if he does a rightclick on the cell, in which case

the cell receives focus and the data inside of it can be changed.

Stopping the rightclick event does not do the trick- the focus still happens.

Sadly, I can't stop the GetFocus event because it only has a "bubble=false" state.

My goal is not to allow the cell to receive focus at all.

Does anybody know a way to overcome this problem or if this is a bug ?

Currently, I am forced to also monitor the Key_Down event in order to

prevent changes to the data in the cell.

Thanks,

Erez

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hello.

Well, according to SAP, there is NO EASY WAY

to perform the block.

Their suggestion comes down to blocking the keydown event.

I am in the processing of requesting a DRQ

in order for them to change that and make the click event always fire as part of the rightclick event.

Tip:

One way a user can change the content of the cell is by rightclicking on it and selecting paste or cut.

In order to avoid that, you need to either stop the rightclick event or TRUNC the Cut, Paste and Del out of the rightclick event popup.

You do that by accessing the accessing the edit menu through code and disabling the above sub menus in the before=true

and returning them in the before=false.

It is very important that doing both of the action be done in a try catch block because

if you try to enable a sub menu (for example cut) that the system disabled, an exception will fly.

Cheers.

Former Member
0 Kudos

Hi Alex.

I need to prevent access to the entire row, so using tab will not the the trick.

Changing the focus by remembering the last item and reverting to it is a nice idea, however I already tried it and there are cases when you can't do it, for example- if the previous item was on a different folder.

I have posted a question with sap and I will update as to thier answer.

Former Member
0 Kudos

Hi,

maybe something like sendkeys("") after your cell got_focus will work.

your cell will still get focus but will loose it immediately. so the user is not able to enter/change the data.

instead of sending TAB you can set the new focus to a specific item or the last active item if you saved that in the lost_focus event.

completely preventing the cell from getting focus is afaik only possible with setting the comlete colum to editable = false.

Alex

Former Member
0 Kudos

Hi Olivier

The EditText object does not have an Enabled property, so your idea will not work.

Hi Ad

As I wrote above, I want to stop monitoring the key_down event, so if you can of another trick...

Thanks,

Erez

AdKerremans
Active Contributor
0 Kudos

Hi Erez,

I thnik a better way is to catch the keydown event and only allow tab and enter. that way the column can not be changed by the user. I use this already myself and it works good.

Regards

Ad

olivier_huet3
Participant
0 Kudos

Hi,

I don't really know if it work but have you tried the "Enabled" property of the EditText in the cell ?

Example :

 oMyMatrix.Columns.Item("My_Column").Cells.Item(MyLineNumber).Specific.Enabled = False 

Olivier