fpiette Posted January 1, 2018 Share Posted January 1, 2018 Create a new application having a UniStringGrid and a UniButton. Use the following code un UniButton1.click event Handler: UniStringGrid1.Row := -1; UniStringGrid1.Com := -1; Clicking on UniButton1 should deselect the currently selected cell in UniStringGrid1. It doesn't work always. Steps to reproduce: 1. Launch application -> No UniStringGrid cell selected -- Correct 2. Click on a UniStringGrid1 cell -> Cell selected and displayed in cyan -- Correct 3. Click UniButton1 -> Nothing happend -- Wrong: cell should be unselected 4. Click on another UniStringGrid cell -> Clicked cell is selected -- Correct -> First selected cell remains cyan (selected) -- Wrong 5. Click on a third UniStringGrid cell -> Cell is selected -- Correct -> Previous selected cell becomes white (unselected) -- Correct -> First selected cell remains cyan (selected) -- Wrong 6. Click UniButton1 -> Last selected cell becomes white (unselected) -- Correct -> First selected cell remains cyan (selected) -- Wrong -- François Piette Embarcadero MVP Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 1, 2018 Share Posted January 1, 2018 Hi, Create a new application having a UniStringGrid and a UniButton. Use the following code un UniButton1.click event Handler: UniStringGrid1.Row := -1; UniStringGrid1.Com := -1; Clicking on UniButton1 should deselect the currently selected cell in UniStringGrid1. It doesn't work always. Are you sure that this should work at all ? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 1, 2018 Share Posted January 1, 2018 3. Click UniButton1 -> Nothing happend -- Wrong: cell should be unselected You can try this: UniStringGrid1.JSInterface.JSCall('getSelectionModel().deselect', []); Quote Link to comment Share on other sites More sharing options...
fpiette Posted January 1, 2018 Author Share Posted January 1, 2018 Yes, this is almost working (Well, there is a typo: Com should be Col. This is because copy/paste doesn't work in the form UI). It works except the first time actually. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 1, 2018 Share Posted January 1, 2018 Yes, this is almost working (Well, there is a typo: Com should be Col. This is because copy/paste doesn't work in the form UI). It works except the first time actually. I meant in VCL Quote Link to comment Share on other sites More sharing options...
fpiette Posted January 1, 2018 Author Share Posted January 1, 2018 UniStringGrid1.JSInterface.JSCall('getSelectionModel().deselect', []); This works. Thanks. In my opinion, UniStringGrid code should do that action in Row/Col property setter whenever the Row/Col value is invalid (Such as -1). Or provide a method to select/unselect a rectangular region in the grid. Quote Link to comment Share on other sites More sharing options...
fpiette Posted January 1, 2018 Author Share Posted January 1, 2018 In VCL, you unselect cell by using the Selection method like this : StringGrid1.Selection := TGridRect(Rect(-1, -1, -1, -1)); uniGUI should implement the same :-) Quote Link to comment Share on other sites More sharing options...
fpiette Posted January 2, 2018 Author Share Posted January 2, 2018 UniStringGrid1.JSInterface.JSCall('getSelectionModel().deselect', []); Actually, this doesn't work 100% correctly. It deselect the cell but affect only the display. Somewhere the underlying layers doesn't know the cell is deselected. This means that clicking again on the [now supposedly unselected] cell doesn't trigger the UniStringGridSelectCell event. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 2, 2018 Share Posted January 2, 2018 We will check Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 2, 2018 Share Posted January 2, 2018 As a workaround, can you try to use this approach too ?: 1. type TMyUniStringGrid = class(TUniBasicGrid) end; 2. with TMyUniStringGrid(UniStringGrid1) do begin JSInterface.JSCall('getSelectionModel().deselect', []); // first CurrCol:=-1; CurrRow:=-1; end; Quote Link to comment Share on other sites More sharing options...
fpiette Posted January 2, 2018 Author Share Posted January 2, 2018 Thanks. As far as I can tell right now, it works. I have implemented a little bit differently, using a old Delphi trick to redefine an existing class (Only valid in current source file). It is enough and natural to call the new method. type TUniStringGrid = class(UniStringGrid.TUniStringGrid) public procedure Deselect; end; procedure TUniStringGrid.Deselect; begin JSInterface.JSCall('getSelectionModel().deselect', []); CurrCol := -1; CurrRow := -1; end; 1 Quote Link to comment Share on other sites More sharing options...
fpiette Posted January 2, 2018 Author Share Posted January 2, 2018 Since we have UniStringGrid source code, I could have put that code directly into the source. Hopefully, the code will be added to next uniGUI release :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.